[Mono-bugs] [Bug 708821] New: System.Text.Decoder.GetChars doesn't work
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Jul 27 21:40:54 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=708821
https://bugzilla.novell.com/show_bug.cgi?id=708821#c0
Summary: System.Text.Decoder.GetChars doesn't work
Classification: Mono
Product: Mono: Class Libraries
Version: 2.10.x
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Core
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: post-christian at freenet.de
QAContact: mono-bugs at lists.ximian.com
CC: post-christian at freenet.de
Found By: Development
Blocker: ---
Description of Problem:
In corlib/System.Text/Decoder.css the function
[CLSCompliant (false)]
[ComVisible (false)]
public unsafe virtual int GetChars (byte* bytes, int byteCount,
char* chars, int charCount, bool flush)
{
CheckArguments (chars, charCount, bytes, byteCount);
char [] carr = new char [charCount];
Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
byte [] barr = new byte [byteCount];
Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount);
return GetChars (barr, 0, byteCount, carr, 0, flush);
}
doesn't make sense. Marshal.Copy ((IntPtr) chars, carr, 0, charCount); copies
an undefinied output buffer to an internal carr buffer and decodes then the
characters into the internal carr buffer. Marshal.Copy should copy carr to the
output buffer after decoding in my mind.
Steps to reproduce the problem:
char[] dst = new char[4];
byte[] src = new byte[] { 65 };
Decoder dec = Encoding.UTF8.GetDecoder();
fixed( char* _dst = dst ) {
fixed( byte* _src = src ) {
if( dec.GetChars( _src, 1, _dst, 1, true ) > 0 )
Console.WriteLine( "character: {0}", (int) *_dst );
}
}
Actual Results:
character: 0
Expected Results:
character: 65
How often does this happen?
everytime
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list