Parcourir la source

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

git-svn-id: trunk@23680 -
yury il y a 12 ans
Parent
commit
5e369ae7fc
1 fichiers modifiés avec 11 ajouts et 7 suppressions
  1. 11 7
      rtl/unix/unixcp.pp

+ 11 - 7
rtl/unix/unixcp.pp

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