Browse Source

* 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 -
marco 6 years ago
parent
commit
f5e684067d
1 changed files with 7 additions and 4 deletions
  1. 7 4
      rtl/win/syswin.inc

+ 7 - 4
rtl/win/syswin.inc

@@ -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);