Re: [fpc-pascal] PChars and AnsiString Code Pages

2016-05-18 Thread Jonas Maebe
Tony Whyman wrote: While the online documentation says a lot about tyepcasting PChars to AnsiStrings, there seems to be nothing on the reverse. You obviously meant the opposite. In any case, ansistring(pchar) results in the same code as ansistring:=pchar, and results in a type conversion tha

Re: [fpc-pascal] PChars and AnsiString Code Pages

2016-05-18 Thread Tony Whyman
On 18/05/16 14:27, Jonas Maebe wrote: s := string(Buf); {seems to work - but should it?} end; Why shouldn't it? Because I couldn't find any documentation saying this should work and I wasn't sure if this worked by luck or design. To repeat what I said in about every message in the prev

Re: [fpc-pascal] PChars and AnsiString Code Pages

2016-05-18 Thread Jonas Maebe
Tony Whyman wrote on Wed, 18 May 2016: I've been looking at some old code which still seems to work in fpc 3.0.0 - but is it safe? The code looks like: {$mode delphi} var Buf: PChar; s: string; begin Buf := LoadString; {returns a pointer to an arbitrarily long null terminated stri