windows phone 7 - Whats going on with this byte array? -


i have byte array: 00 01 00 00 00 12 81 00 00 01 00 c8 00 00 00 00 00 08 5c 9f 4f a5 09 45 d4 ce

it read via streamreader using utf8 encoding

// note can't change code, many component dependent on it. using (streamreader streamreader =      new streamreader(responsestream, encoding.utf8, false)) {     string streamdata = streamreader.readtoend();     if (requestdata.callback != null)     {         requestdata.callback(response, streamdata);     } } 

when function runs following returned me (i converted byte array)

00 01 00 00 00 12 ef bf bd 00 00 01 00 ef bf bd 00 00 00 00 00 08 5c ef bf bd 4f ef bf bd 09 45 ef bf bd

somehow need take whats returned me , right encoding , right byte array, i've tried alot.

please aware, i'm working wp7 limited api.

hopefully guys can help.

thanks!

update help...

if following code, it's right, thing wrong 5th last byte gets split out.

byte[] writebuf1 = system.text.encoding.utf8.getbytes(data);                     string buf1string = system.text.encoding.bigendianunicode.getstring(writebuf1, 0, writebuf1.length);                     byte[] writebuf = system.text.encoding.bigendianunicode.getbytes(buf1string); 

the original byte array not encoded utf-8. streamreader therefore replaces each invalid byte replacement character u+fffd. when character gets encoded utf-8, results in byte sequence ef bf bd. cannot construct original byte value string because information lost.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -