* Use UTF-8 as fallback code page on linux and ASCII on other unix systems.

git-svn-id: trunk@23680 -
This commit is contained in:
yury 2013-03-02 09:51:05 +00:00
parent 72e81d4be8
commit 5e369ae7fc

View File

@ -700,26 +700,30 @@ function GetSystemCodepage: TSystemCodePage;
var
p: SizeInt;
lang: ansistring;
cp: TSystemCodePage;
begin
// Get one of non-empty environment variables in the next order:
// LC_ALL, LC_CTYPE, LANG. Default is ASCII.
// LC_ALL, LC_CTYPE, LANG. Default is UTF-8 or ASCII.
{$ifdef linux}
Result:=CP_UTF8;
{$else}
Result:=CP_ASCII;
{$endif linux}
lang:=FpGetEnv('LC_ALL');
if lang='' then
lang:=FpGetEnv('LC_CTYPE');
if lang='' then
lang:=FpGetEnv('LANG');
if lang='' then
Result:=CP_ASCII
else
if lang<>'' then
begin
// clean up, for example en_US.UTF-8 => UTF-8
p:=Pos('.',lang);
if p>0 then Delete(lang,1,p);
p:=Pos('@',lang);
if p>0 then Delete(lang,p,length(lang)-p+1);
Result:=GetCodepageByName(lang);
if Result = CP_NONE then
Result:=CP_ASCII;
cp:=GetCodepageByName(lang);
if cp <> CP_NONE then
Result:=cp;
end;
end;