How do I convert a byte array to a string (base 256) in Delphi?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the built-in
SetStringcommand. It sets the string to the required length and copies the bytes. There’s no need for the array to be null-terminated. In fact, if the array has zero–valued bytes in it, they’ll correctly appear within the string; they won’t terminate the string.If you have a
UnicodeString, then you’ll need to halve the length parameter since it measures characters, not bytes:See also, Converting TMemoryStream to String in Delphi 2009.