浏览代码

* Use UTF-8 as fallback in GetSystemCodepage.

git-svn-id: trunk@23673 -
yury 12 年之前
父节点
当前提交
b0d79b7854
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      rtl/unix/unixcp.pp

+ 5 - 3
rtl/unix/unixcp.pp

@@ -693,7 +693,7 @@ begin
           exit;
           exit;
         end;
         end;
   { rawbytestring (or better raise an error?) }
   { rawbytestring (or better raise an error?) }
-  result:=65535;
+  result:=CP_NONE;
 end;
 end;
 
 
 function GetSystemCodepage: TSystemCodePage;
 function GetSystemCodepage: TSystemCodePage;
@@ -702,14 +702,14 @@ var
   lang: ansistring;
   lang: ansistring;
 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 CP_UTF8.
   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:=0
+    Result:=CP_UTF8
   else
   else
     begin
     begin
       // clean up, for example en_US.UTF-8 => UTF-8
       // clean up, for example en_US.UTF-8 => UTF-8
@@ -718,6 +718,8 @@ begin
       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);
       Result:=GetCodepageByName(lang);
+      if Result = CP_NONE then
+        Result:=CP_UTF8;
     end;
     end;
 end;
 end;