- #1
Silicon Waffle
- 160
- 203
I have a byte array (each character consumes 4 bytes) of size 64 for example,
Now I decode it using
Amazingly, after the code is executed, s="zýó";
But if my bytes contains string e.g "劉三好" (byte array should be all numbers representing these Chinese characters), then after I execute the above code line I get this string too. How can that be done ?
Now I decode it using
Code:
byte[] bytes={'z','\0','\0','\0','ý','\0','\0','\0','ó','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0',...};
string s=Encoding.Unicode.GetString(bytes);
Amazingly, after the code is executed, s="zýó";
But if my bytes contains string e.g "劉三好" (byte array should be all numbers representing these Chinese characters), then after I execute the above code line I get this string too. How can that be done ?