Bug 4025 - encoding:Incorrect international character convertion on uncommon codepages (437,1251,etc), possibly memory corruption
Summary: encoding:Incorrect international character convertion on uncommon codepages (...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2012-03-22 04:26 UTC by 1
Modified: 2016-02-15 16:48 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
sample code (1.01 KB, text/plain)
2012-03-22 04:26 UTC, 1
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description 1 2012-03-22 04:26:59 UTC
Created attachment 1553 [details]
sample code

System.Text.Encoding.GetEncoding(437).GetBytes("\u0416" + "234") produces wrong result - unicode character is converted to two bytes 0x3F,0x16, last character or  string is lost after convertion. 

Expected result: 0x3F 0x32 0x33 0x34 ("?234")
Actual result:   0x3F 0x16 0x32 0x33 ("?▬23")
Comment 1 Rebex.NET 2013-08-13 10:21:10 UTC
We're encountering the same bug (in Mono 2.10.2) for ISO-8859-2 for several characters. 

It is strange that there has been no answer for more then a year. 

Repro:

// Original string: 01-78-41
string s = "\u0178\u0041";

// Expected result: 3F-41
// Actual   result: 3F-41
byte[] iso1 = System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(s);
Console.WriteLine(BitConverter.ToString(iso1));

// Expected result: 3F-41
// Actual   result: 3F-37  (41 is missing)
byte[] iso2 = System.Text.Encoding.GetEncoding("iso-8859-2").GetBytes(s);
Console.WriteLine(BitConverter.ToString(iso2));
Comment 2 marcos.henrich 2016-02-15 16:48:47 UTC
Both use cases are fixed in mono 4.2.