diff --git a/components/lazutils/winlazutf8.inc b/components/lazutils/winlazutf8.inc index d325bce94d..15c30c3b87 100644 --- a/components/lazutils/winlazutf8.inc +++ b/components/lazutils/winlazutf8.inc @@ -51,6 +51,21 @@ begin end; {$endif} +{$ifndef wince} +procedure SetupArgvAsUtf8; +var + i: Integer; +begin + SetLength(ArgsUTF8,length(ArgsW)); + OldArgV:=argv; + GetMem(argv,SizeOf(Pointer)*length(ArgsW)); + for i:=0 to length(ArgsW)-1 do + begin + ArgsUTF8[i]:=ArgsW{%H-}[i]; + argv[i]:=PChar(ArgsUTF8[i]); + end; +end; +{$endif} procedure SetupCommandlineParametersWide; var @@ -187,18 +202,12 @@ begin end; Dec(ArgsWCount); - - {$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)} - if DefaultSystemCodePage=CP_UTF8 then begin - SetLength(ArgsUTF8,length(ArgsW)); - OldArgV:=argv; - GetMem(argv,SizeOf(Pointer)*length(ArgsW)); - for i:=0 to length(ArgsW)-1 do - begin - ArgsUTF8[i]:=ArgsW{%H-}[i]; - argv[i]:=PChar(ArgsUTF8[i]); - end; - end; + //Note: + //On WinCe Argsv is a static function, so we cannot change it. + //This might change in the future if Argsv on WinCE will be declared as a function variable + {$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL) AND NOT DEFINED(WINCE)} + if DefaultSystemCodePage=CP_UTF8 then + SetupArgvAsUtf8; {$IFEND} end; @@ -349,13 +358,16 @@ end; function GetLocaleCharUTF8(aLocaleID, aLCType: Longint; Def: Char): Char; var - Buf: array[0..3] of Char; // sdate allows 4 chars. + Buf: array[0..3] of WChar; // sdate allows 4 chars. + GLI: LongInt; begin - if (GetLocaleInfoA(aLocaleID, aLCType, Buf, sizeof(buf)) > 0) - and (ord(Buf[0])<128) then + //Use Widestring Api so it works on WinCE as well + GLI := GetLocaleInfoW(aLocaleID, aLCType, Buf, sizeof(buf)); + if (GLI > 0) and (ord(Buf[0])<128) then Result := Buf[0] else begin Result := Def; + { case Buf[0] of #$C2: case Buf[1] of @@ -383,6 +395,35 @@ begin #$8E: if Buf[2]=#$96 then Result := ''''; // codepoint 9110 decimal separator end; end; + } + if (GLI = 1) then begin + case Buf[0] of + #$00A0: Result := ' '; // non breakable space + #$00B7: Result := '.'; // middle stop + #$02D9: Result := ''''; // dot above, italian handwriting + #$066B: Result := ','; // arabic decimal separator, persian thousand separator + #$066C: Result := ''''; // arabic thousand separator + #$2002: Result := ' '; // long space + #$2003: Result := ' '; // long space + #$2009: Result := ' '; // thin space + #$202F: Result := ' '; // narrow non breakable space + #$2014: Result := '-'; // persian decimal mark + #$2396: Result := ''''; // codepoint 9110 decimal separator + { Utf8 Utf16 + C2 A0 -> 00A0 + C2 B7 -> 00B7 + CB 99 -> 02D9 + D9 AB -> 066B + D9 AC -> 066C + E2 80 82 -> 2002 + E2 80 83 -> 2003 + E2 80 89 -> 2009 + E2 80 AF -> 202F + E2 80 94 -> 2014 + E2 8E 96 -> 2396 + } + end; //case + end; //GLI = 1 end; end; @@ -494,7 +535,11 @@ begin end; end; {$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)} + {$ifndef wince} GetFormatSettingsUTF8(GetThreadLocale,FormatSettings); + {$else} + GetFormatSettingsUTF8(GetUserDefaultLCID ,FormatSettings); + {$endif} widestringmanager.UpperAnsiStringProc:=@UTF8UpperString; widestringmanager.LowerAnsiStringProc:=@UTF8LowerString; widestringmanager.CompareStrAnsiStringProc:=@UTF8CompareStr; @@ -515,7 +560,7 @@ var p: PPChar; {$IFEND} begin - {$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)} + {$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL) AND NOT DEFINED(WINCE)} // restore argv and free memory if OldArgV<>nil then begin