UCS and BMP Character Sets

  • Thread starter Thread starter Jeffrey Walton
  • Start date Start date
Jeffrey Walton said:
I' working on an ASN.1 parser. The Content Octets (data values) are
stored in a byte[]. The conversion of byte[] to char[] is fairly
trivial. BMP is a special case of UCS, using the lower 65 thousand
characters.

How do I specify a character set of UCS (ISO/IEC 10646) when invoking
a string constructor?

You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).

You want to use System.Text.Encoding.GetString(byte[]) to convert from
bytes to a string.
 
Hi John,

Thanks for the quick reply.
You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).
I know I am off slightly with respect to the paradigm.
You want to use System.Text.Encoding.GetString(byte[]) to convert from
bytes to a string.
Thank you very much. I was cruising your site earlier. The example
presented is based on a Stream (but I have a byte array). I was hoping
for a more applicable answer.

I also saw a T.61 string is availble as a CodePage (http://
msdn2.microsoft.com/en-us/library/system.text.encodinginfo.aspx). How
does on set it in C# (or is there an overload in
System.Text.Encoding.GetString() which uses it?).


Thanks Again,
Jeff



Jeffrey Walton said:
I' working on an ASN.1 parser. The Content Octets (data values) are
stored in a byte[]. The conversion of byte[] to char[] is fairly
trivial. BMP is a special case of UCS, using the lower 65 thousand
characters.

How do I specify a character set of UCS (ISO/IEC 10646) when invoking
a string constructor?

You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).

You want to use System.Text.Encoding.GetString(byte[]) to convert from
bytes to a string.
 
Jeffrey Walton said:
You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).
I know I am off slightly with respect to the paradigm.
You want to use System.Text.Encoding.GetString(byte[]) to convert from
bytes to a string.
Thank you very much. I was cruising your site earlier. The example
presented is based on a Stream (but I have a byte array). I was hoping
for a more applicable answer.

Okay, to load a string from a Stream, you use a StreamReader with a
suitable Encoding.
I also saw a T.61 string is availble as a CodePage (http://
msdn2.microsoft.com/en-us/library/system.text.encodinginfo.aspx). How
does on set it in C# (or is there an overload in
System.Text.Encoding.GetString() which uses it?).

You can supply a code page to Encoding.GetEncoding.
 
Back
Top