YASQ - Proper way to convert byte[] <--> string
Steve Teale
steve.teale at britseyeview.com
Wed Jul 11 23:21:01 PDT 2007
I have a byte[] A that contains an AJP13 packet, presumably including UTF8 strings. I need to extract such strings and to place strings in such a buffer. I'm using:
string s = A[n .. m].dup; // n and m from prefixed string length/position
return s;
to get strings, and
byte[] ba = cast(byte[]) s;
A[n .. n+ba.length] = ba[0 .. $].dup;
to put them. Are these a) sensible, b) optimal?
More information about the Digitalmars-d
mailing list