mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-05 09:38:47 +02:00
* 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:
parent
72e81d4be8
commit
5e369ae7fc
@ -700,26 +700,30 @@ function GetSystemCodepage: TSystemCodePage;
|
|||||||
var
|
var
|
||||||
p: SizeInt;
|
p: SizeInt;
|
||||||
lang: ansistring;
|
lang: ansistring;
|
||||||
|
cp: TSystemCodePage;
|
||||||
begin
|
begin
|
||||||
// Get one of non-empty environment variables in the next order:
|
// 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');
|
lang:=FpGetEnv('LC_ALL');
|
||||||
if lang='' then
|
if lang='' then
|
||||||
lang:=FpGetEnv('LC_CTYPE');
|
lang:=FpGetEnv('LC_CTYPE');
|
||||||
if lang='' then
|
if lang='' then
|
||||||
lang:=FpGetEnv('LANG');
|
lang:=FpGetEnv('LANG');
|
||||||
if lang='' then
|
if lang<>'' then
|
||||||
Result:=CP_ASCII
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
// clean up, for example en_US.UTF-8 => UTF-8
|
// clean up, for example en_US.UTF-8 => UTF-8
|
||||||
p:=Pos('.',lang);
|
p:=Pos('.',lang);
|
||||||
if p>0 then Delete(lang,1,p);
|
if p>0 then Delete(lang,1,p);
|
||||||
p:=Pos('@',lang);
|
p:=Pos('@',lang);
|
||||||
if p>0 then Delete(lang,p,length(lang)-p+1);
|
if p>0 then Delete(lang,p,length(lang)-p+1);
|
||||||
Result:=GetCodepageByName(lang);
|
cp:=GetCodepageByName(lang);
|
||||||
if Result = CP_NONE then
|
if cp <> CP_NONE then
|
||||||
Result:=CP_ASCII;
|
Result:=cp;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user