[fpc-pascal] Byte array manipulation
Wimpie Nortje
wimpienortje at gmail.com
Sun Aug 16 21:17:31 CEST 2009
theo wrote:
> AnsiString does not have problems with #0.
>
> Test:
>
> var aStr:AnsiString;
> begin
> aStr:='test-test-test';
> aStr:=StringReplace(aStr,'-',#0,[rfReplaceAll]);
> //if you ouput now, you'll only see 'test'...
> aStr:=StringReplace(aStr,#0,'-',[rfReplaceAll]);
> //...but the text is still in the String;
> Edit1.text:=aStr;
> end;
Thanks. I tested it and it works.
The reference manual is a bit confusing though:
"Ansistrings are strings that have no length limit. They are reference
counted and null terminated."
"i.e. a variable of type PChar is a pointer that points to an array of
type Char, which is ended by a null-character (#0). "
The above quotes does not agree with the code above, which makes
discovering this info a bit difficult.
More information about the fpc-pascal
mailing list