[fpc-devel] Performance of string handling in trunk

Michael Schnell mschnell at lumino.de
Wed Jun 26 15:41:10 CEST 2013

On 06/26/2013 02:59 PM, Sven Barth wrote:
>  ... And using SetCodePage you can force a conversion.

The docs say:

procedure  SetCodePage(var  S:  RawByteString;  CodePage:  Word;  Convert:  Boolean);

Mit der Routine *SetCodePage* setzen Sie die Codeseite für eine 


This also is compatible with my suggestion:

If the RawByteString Variable already has a dynamic encoding type other than $FFFF a conversion might or might not be necessary.

This is the same action as assigning a string from a RawByte String.

Thus the function could use an intermediate string variable and set it's dynamic encoding type field to "CodePage", andjust call
the same conversion function as compiler magic does when assigning strings.

The conversion function does not use the static encoding type of it's  arguments (it even can't know same). So it will do the
appropriate conversion, even if the target in the calling function is a RawByteString. (In fact it  will never be called
with a RawByteString target, when the compiler magic creates the call instead of manually done by theSetCodePage programming)

I see no problem here either.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130626/22240180/attachment.html>

More information about the fpc-devel mailing list