[fpc-pascal] Weird string behavior
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Jul 25 23:23:23 CEST 2016
On 25/07/16 23:07, Mattias Gaertner wrote:
> DefaultSystemCodePage = 1252
> s3 = "abcdef" cp = 65001
Thanks. So the rule for concatenation appears to be:
* the dynamic code page of the result of a string concatenation is that
of the left operand (except if it's an empty string, then it's that of
the right operand)
* the declared code page of the final concatenation result is that of
the left operand
You then process the assignment as if you are assigning a string with
the above declared/dynamic code page to whatever you are assigning the
result of the concatenation to (which means no code page conversion in
case the declared code pages match, like in the above case).
That's indeed not what FPC does currently. It's mainly complicated by
the fact that FPC contains optimised helpers to avoid the final
assignment if possible and directly concatenate into the destination
when possible (those helpers right now only get passed the declared code
page of the final destination, and not that of the concatenation, and
hence virtually always convert the result to the dynamic code page of
the destination at this time -- there are some exceptions for rawbytestring)
Jonas
More information about the fpc-pascal
mailing list