* turn off MB_PRECOMPOSED for encodings named in MSDN multibytetowidechar function, as detailed by Aserge in https://forum.lazarus.freepascal.org/index.php?topic=45380.0;topicseen

git-svn-id: trunk@42043 -
This commit is contained in:
marco 2019-05-12 14:18:36 +00:00
parent 60efc9e81c
commit f5e684067d

View File

@ -591,10 +591,13 @@ procedure Win32Ansi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:Unico
begin
// retrieve length including trailing #0
// not anymore, because this must also be usable for single characters
if cp=CP_UTF8 then
dwFlags:=0
else
dwFlags:=MB_PRECOMPOSED;
case cp of
// Under https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar
CP_UTF8, CP_UTF7, 50220, 50221, 50222, 50225, 50227, 50229, 57002..57011, 42:
dwFlags:=0
else
dwFlags:=MB_PRECOMPOSED;
end;
destlen:=MultiByteToWideChar(cp, dwFlags, source, len, nil, 0);
// this will null-terminate
setlength(dest, destlen);