Delphi - Convert byte array to string -
how convert byte array string (base 256) in delphi?
use built-in setstring
command. sets string required length , copies bytes. there's no need array null-terminated. in fact, if array has zero--valued bytes in it, they'll correctly appear within string; won't terminate string.
setstring(ansistr, pansichar(@bytearray[0]), lengthofbytearray);
if have unicodestring
, you'll need halve length parameter since measures characters, not bytes:
setstring(unicodestr, pwidechar(@bytearray[0]), lengthofbytearray div 2);
Comments
Post a Comment