Hi there, a quick freepascal question: i have a buffer with some data (including zeroes). Is there a way i can make it into a regular ansistring?
I know i can get a string from a pchar with strpas or simply casting, but this buffer possibly have zeroes inside and i can't find a function to do that.
I've tryed using setLength and then copy the memory but gives error..
String with nulls inside
Re: String with nulls inside
I regularly do something similar
If you have buff as a pointer and bufflen as the length of data and s as the string
SetLength (s, bufflen);
System.Move (buff^, s[1], bufflen);
Regards
Paul
If you have buff as a pointer and bufflen as the length of data and s as the string
SetLength (s, bufflen);
System.Move (buff^, s[1], bufflen);
Regards
Paul
Re: String with nulls inside
Thanks, in the meantime i also found setStringthat does exacly what i needed 

Who is online
Users browsing this forum: No registered users and 3 guests