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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to