Bug 33412 - Mono fails to convert string to Thai encoding CP874
Summary: Mono fails to convert string to Thai encoding CP874
Alias: None
Product: Class Libraries
Classification: Mono
Component: General ()
Version: 3.12.0
Hardware: PC Mac OS
: High normal
Target Milestone: Untriaged
Assignee: marcos.henrich
Depends on:
Reported: 2015-08-27 01:58 UTC by Prashant Cholachagudda
Modified: 2016-02-15 13:22 UTC (History)
3 users (show)

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

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:

Description Prashant Cholachagudda 2015-08-27 01:58:28 UTC
Below code fails to convert string to CP874 encoding.

   byte[] bytes = Encoding.UTF8.GetBytes("Test text");
   byte[] cp874 = Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding("CP874"), bytes);

# Stacktrace

System.ArgumentException: 'CP874' is not a supported encoding name.
Parameter name: name
  at System.Globalization.EncodingTable.internalGetCodePageFromName (System.String name) [0x0009a] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/mcs/class/corlib/ReferenceSources/EncodingTable.cs:799
  at System.Globalization.EncodingTable.GetCodePageFromName (System.String name) [0x0002a] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/mcs/class/corlib/ReferenceSources/EncodingTable.cs:862
  at System.Text.Encoding.GetEncoding (System.String name) [0x00000] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/external/referencesource/mscorlib/system/text/encoding.cs:651
  at myHealthCheck360.Controllers.FriendsListViewController.ViewDidAppear (Boolean animated) [0x0001b] in /Users/prashantvc/Desktop items/Xamarin/192314/MyHealthcheck360iOS/myHealthCheck360/Controllers/FriendsListViewController.cs:29
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/1977/2c66d2fe/source/maccore/src/UIKit/UIApplication.cs:63
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/1977/2c66d2fe/source/maccore/src/UIKit/UIApplication.cs:47
  at myHealthCheck360.Application.Main (System.String[] args) [0x00008] in /Users/prashantvc/Desktop items/Xamarin/192314/MyHealthcheck360iOS/myHealthCheck360/Main.cs:12
Comment 1 Rodrigo Kumpera 2015-09-03 17:30:51 UTC
Hi Marcos,

Could you look into this issue?

It would be nice to get it fixed in 4.2.
Comment 2 marcos.henrich 2015-09-14 11:57:57 UTC
Hi Prashant,

I think the encoding you are trying to use is named as "windows-874" in .NET and Mono.

byte[] bytes = Encoding.UTF8.GetBytes("Test text");
byte[] cp874 = Encoding.Convert(Encoding.UTF8,Encoding.GetEncoding("windows-874"), bytes);

Does the code above do what you are looking for?
Comment 3 marcos.henrich 2016-02-15 13:22:49 UTC
The encoding named "CP874" is not valid on .NET nor in Mono, still it should be available through "windows-874", thus I am marking this as a feature.