mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-11 01:58:12 +02:00
LCL: added a simple heruistic to find the windows local ID
git-svn-id: trunk@14924 -
This commit is contained in:
parent
aeee3bb375
commit
764f3bb7ad
@ -84,10 +84,34 @@ procedure GetSupportedEncodings(List: TStrings);
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$IFDEF Windows}
|
||||||
|
uses Windows;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
var EncodingValid: boolean = false;
|
var EncodingValid: boolean = false;
|
||||||
SystemEncoding: string = EncodingAnsi;
|
SystemEncoding: string = EncodingAnsi;
|
||||||
|
|
||||||
|
{$IFDEF Windows}
|
||||||
|
function GetWindowsEncoding: string;
|
||||||
|
var
|
||||||
|
Buffer : PChar;
|
||||||
|
Size : integer;
|
||||||
|
begin
|
||||||
|
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, nil, 0);
|
||||||
|
GetMem(Buffer, Size);
|
||||||
|
try
|
||||||
|
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, Buffer, Size);
|
||||||
|
Result := string(Buffer);
|
||||||
|
while (Result<>'') and (Result[1]='0') do
|
||||||
|
Result:=copy(Result,2,length(Result));
|
||||||
|
if Result<>'' then
|
||||||
|
Result:='cp'+Result;
|
||||||
|
finally
|
||||||
|
FreeMem(Buffer);
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
function GetSystemEncoding: string;
|
function GetSystemEncoding: string;
|
||||||
var Lang: string;
|
var Lang: string;
|
||||||
i: integer;
|
i: integer;
|
||||||
@ -98,7 +122,12 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF Windows}
|
||||||
|
Result:=GetWindowsEncoding;
|
||||||
|
{$ELSE}
|
||||||
Result:=EncodingAnsi;
|
Result:=EncodingAnsi;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
lang := GetEnv('LC_ALL');
|
lang := GetEnv('LC_ALL');
|
||||||
if Length(lang) = 0 then
|
if Length(lang) = 0 then
|
||||||
begin
|
begin
|
||||||
|
@ -53,8 +53,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, FileUtil, StringHashList
|
Classes, SysUtils, LCLProc, FileUtil, StringHashList
|
||||||
{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF}
|
{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF};
|
||||||
{$IFDEF MultiLocale},LConvEncoding{$ENDIF};
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TPOFileItem }
|
{ TPOFileItem }
|
||||||
@ -98,28 +97,19 @@ procedure TranslateUnitResourceStrings(const ResUnitName, BaseFilename,
|
|||||||
Lang, FallbackLang: string);
|
Lang, FallbackLang: string);
|
||||||
function TranslateUnitResourceStrings(const ResUnitName, AFilename: string
|
function TranslateUnitResourceStrings(const ResUnitName, AFilename: string
|
||||||
): boolean;
|
): boolean;
|
||||||
function UTF8ToSystemCharSet(const s: string): string;
|
function UTF8ToSystemCharSet(const s: string): string; inline;
|
||||||
{$ifndef MultiLocale} inline;{$endif}
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function UTF8ToSystemCharSet(const s: string): string; {$ifndef MultiLocale} inline;{$endif}
|
function UTF8ToSystemCharSet(const s: string): string; inline;
|
||||||
begin
|
begin
|
||||||
if SystemCharSetIsUTF8 then
|
if SystemCharSetIsUTF8 then
|
||||||
exit(s);
|
exit(s);
|
||||||
{$IFDEF NoUTF8Translations}
|
{$IFDEF NoUTF8Translations}
|
||||||
Result:=s;
|
Result:=s;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFNDEF MultiLocale}
|
Result:=Utf8ToAnsi(s);
|
||||||
Result:=Utf8ToAnsi(s);
|
|
||||||
{$ELSE}
|
|
||||||
try
|
|
||||||
if (LowerCase(GetDefaultCodepage)<>'utf8')
|
|
||||||
and (LowerCase(GetDefaultCodepage)<>'utf-8')then
|
|
||||||
Result:=CPConvert(s,'utf8',LowerCase(GetDefaultCodepage)) else Result:=s;
|
|
||||||
except Result:=s;end;
|
|
||||||
{$ENDIF}
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user