[fpc-pascal] Weird string behavior
jonas.maebe at elis.ugent.be
Fri Jul 22 17:56:32 CEST 2016
On 22/07/16 17:33, Santiago A. wrote:
> ResultA := AnsiToUTF8(AnsiStrA + AnsiStrA); // UTF-8 ResultB :=
> AnsiToUTF8(AnsiStrA) + AnsiToUTF8(AnsiStrA); // Win-1252
> And resultA is not equal to ResultB
> It doesn't look like too intuitive.
It would be good if someone with access to Delphi 2009+ could test this.
It is possible that the result of concatenating two RawByteStrings
should again be a RawByteString and that hence no conversion should
happen on assignment here either.
> I would say that it is closer to "hidden secret knowledge" than to the
> "Principle of least surprise".
There is no hidden secret knowledge. Everything is documented and the
information is linked from the release notes. The "principle of least
surprise" has been applied in the sense that we didn't invent our own
system that introduces small or large differences compared to how Delphi
behaves in the same situation (and if there are differences, then those
are bugs in our implementation).
More information about the fpc-pascal