Q
qushui_chen
I store the MSSqlServer is Nvarchar(unicode),
the store data as "我就是我文本",
How can i decode in C#?
the store data as "我就是我文本",
How can i decode in C#?
Dmitriy Lapshin said:First parse the string to extract the numbers themselves and store them in
an array of ints. Then split each number to a couple of bytes (the high byte
is obtained as
(theNumber & 0xff00) >> 8
and the low one as
(theNumber & 0xff)
The resultant bytes should be stored in a byte array with capacity equal to
doubled number of character codes.
The low bytes should be stored first (i.e. in even indexes - 0, 2, 4) and
the high bytes second (in odd indexes - 1, 3, 5)
When the byte array is ready, use code like this:
string result = System.Text.Encoding.Unicode.GetString(theBytes);
How can i decode in C#?