Help with \0 terminated strings in C#
Posted
by Joshua
on Stack Overflow
See other posts from Stack Overflow
or by Joshua
Published on 2010-04-05T21:35:44Z
Indexed on
2010/04/05
21:43 UTC
Read the original article
Hit count: 248
I'm using a low level native API where I send an unsafe byte buffer pointer to get a c-string value.
So it gives me
// using byte[255] c_str
string s = new string(Encoding.ASCII.GetChars(c_str));
// now s == "heresastring\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0(etc)";
So obviously I'm not doing it right, how I get rid of the excess?
© Stack Overflow or respective owner