But I thought the encoding / code page is only relevant for AnsiString, and not for ShortString.
Like
AnsiString,
ShortString is an
AnsiChar-based string type, so assigning a Unicode string to it requires an ANSI charset/codepage conversion at runtime. A charset-aware
AnsiString knows the encoding it's currently holding (stored in the string's metadata), but a
ShortString does not (nowhere to store it), so it relies on the system encoding.
Sorry, Delphi shortstring and string are generic UNICODE STRING
A
ShortString, whether in Delphi or FreePascal, is NOT a Unicode string from the compiler's perspective, although it
can hold UTF-8 elements at runtime.