[fpc-pascal] Concatenating CP Strings
listbox at martoks-place.de
Sat Sep 15 13:55:37 CEST 2018
Am 15.09.2018 um 07:34 schrieb Mattias Gaertner via fpc-pascal:
> To have the result in a specific codepage use
As I wrote, doing this by hand works, but I don't want to believe somebody
thought that was how it should be. Why would "CP_UTF16 + CP_UTF8(literal) =
cp1252" be the desired outcome?
operator >< (a, b: RawByteString): RawByteString;
la, lt: Integer;
SetCodePage(t, StringCodePage(a), True);
SetLength(Result, la + lt);
Move(t, Result[la+1], lt);
With that, one can write "foo:= bar >< x" and it just works.
> Only on ancient Windows it was UCS2.
In that case, fpwidestring is wrong as well, see fpwidestring.pp:262.
MSDN is slightly unclear:
Unicode UTF-16, little endian byte order (BMP of ISO 10646);
available only to managed applications"
The "managed applications" part is why WideCharToMultiByte simply returns an
empty string when asked to convert anything to cp1200, instead of just doing the
"only the BMP" would be UCS2. In other places, surrogate pairs are mentioned,
making it a true UTF encoding.
In any case, I think the RTL should be consistent across platforms?
More information about the fpc-pascal