tequilaras
tequilaras

Reputation: 279

How to store a UTF-16 character as a string in c#?

How can I print a character whose UTF-16 representation is feff2031?

When I try the following I get "?" as the result:

String million = "\u2030";

The character I want is "per million". See PER MILLE for more information.

UTF-8 (hex)     0xE2 0x80 0xB0 (e280b0)
UTF-8 (binary)  11100010:10000000:10110000
UTF-16 (hex)    0x2030 (2030)
UTF-16 (decimal)    8240
UTF-32 (hex)    0x00002030 (2030)
UTF-32 (decimal)    8240
C/C++/Java source code  "\u2030"
Python source code  u"\u2030"

Upvotes: 2

Views: 1413

Answers (2)

McKay
McKay

Reputation: 12604

Encoding.Unicode.GetString(bytes);

Upvotes: 0

McKay
McKay

Reputation: 12604

        label1.Text = "\u2030";

That shows up in a windows form I just tried;enter image description here

Upvotes: 3

Related Questions