all groups > dotnet internationalization > august 2007 >
You're in the

dotnet internationalization

group:

utf32 65005 or 12000


utf32 65005 or 12000 Bob Bins
8/7/2007 10:20:50 AM
dotnet internationalization:
If you look at the MSDN sample for Encoding.GetEncoding Method (Int32) it
shows the below sample code..
// Get a UTF-32 encoding by codepage.
Encoding e1 = Encoding.GetEncoding( 65005 );

// Get a UTF-32 encoding by name.
Encoding e2 = Encoding.GetEncoding( "utf-32" );

// Check their equality.
Console.WriteLine( "e1 equals e2? {0}", e1.Equals( e2 ) );


The problem is that the first line throws an exception:
System.NotSupportedException Additional information: No data is available
for encoding 65005.

If I look at the code page property when using the "utf-32" string it says
12000.

Which one is correct? Why does the sample show 65005 as utf-32 when the
function thinks 12000 is the utf32 codepage?

Re: utf32 65005 or 12000 Mihai N.
8/7/2007 8:35:52 PM
[quoted text, click to view]

12000 is UTF-32LE (little-endian) and 12001 is UTF-32BE (big-endian),
if you still want to go by codepage.

But I find that getting the encoder by name (or using Encoding.UTF32)
is much more readable than 12000

I tend to use the System.Text.UTF32Encoding, because it gives me control
on byte-endiannes and BOM.


--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Re: utf32 65005 or 12000 Bob
8/13/2007 11:45:49 AM
So the sample is just a documentation bug/error?

// Get a UTF-32 encoding by codepage.
Encoding e1 = Encoding.GetEncoding( 65005 );

http://msdn2.microsoft.com/en-us/library/wzsz3bk3.aspx


[quoted text, click to view]

Re: utf32 65005 or 12000 Michael S. Kaplan [MSFT]
8/13/2007 8:07:03 PM
Correct.


--
MichKa [Microsoft]
NLS Collation/Locale/Keyboard Technical Lead
Globalization Infrastructure, Fonts, and Tools
Blog: http://blogs.msdn.com/michkap

This posting is provided "AS IS" with
no warranties, and confers no rights.



[quoted text, click to view]

AddThis Social Bookmark Button