[fpc-devel] Performance of string handling in trunk

Marco van de Voort marcov at stack.nl
Wed Jun 26 17:07:00 CEST 2013


In our previous episode, Michael Schnell said:
> On 06/26/2013 03:44 PM, Marco van de Voort wrote:
> > There never is a conversion when assigning to/from rawbytestring, so 
> > this is a strange line.
> 
> Sven replied to my contribution that suggested an implementation that in 
> fact does a conversion when doing an assignment from a RawByteString to 
> a normal String when appropriate.
> The what _is_ (in DXE) is not discussed here (other than as a subject of 
> comparing).

I was thinking about the below code that returns "1" in Windows and "0" in
Linux. Specially the windows answer is interesting. The Linux result can
probably be explained by non implementation of the windows specific OEM
codepage concept.

{$mode delphiunicode}
const cp_oemcp=1;

type oemstring = type ansistring(cp_OEMCP);

function xx:ansistring;

var nn:rawbytestring;
begin
  setlength(nn,1);
  nn[1]:=#121;
  setcodepage(nn,cp_oemcp);
  result:=nn;
end;

var v : ansistring;

begin
 v:=xx;
 writeln(stringcodepage(v));
end.



More information about the fpc-devel mailing list