Browse Source

merge r17330 from cpstrnew branch by michael:
* Patch from Inoussa, fixing tunistr1.pp and twide1.pp

git-svn-id: trunk@19107 -

paul 14 years ago
parent
commit
7fd7eee1c9
3 changed files with 21 additions and 5 deletions
  1. 3 3
      compiler/ncnv.pas
  2. 7 1
      rtl/inc/ustrings.inc
  3. 11 1
      rtl/inc/wstrings.inc

+ 3 - 3
compiler/ncnv.pas

@@ -2918,9 +2918,9 @@ implementation
         else if (tstringdef(resultdef).stringtype=st_ansistring) and
             ((tstringdef(left.resultdef).stringtype in [st_widestring,st_unicodestring]) or
              { ansistring to ansistring and no RawByteString envolved? }
-             ((tstringdef(resultdef).encoding<>65535) and
-              (tstringdef(left.resultdef).stringtype=st_ansistring) and
-              (tstringdef(left.resultdef).encoding<>65535)
+             (//(tstringdef(resultdef).encoding<>65535) and
+              (tstringdef(left.resultdef).stringtype=st_ansistring) 
+              //(tstringdef(left.resultdef).encoding<>65535)
              )
             ) then
             result:=ccallnode.createinternres(procname,

+ 7 - 1
rtl/inc/ustrings.inc

@@ -340,11 +340,17 @@ Function fpc_AnsiStr_To_UnicodeStr (Const S2 : RawByteString): UnicodeString; co
 }
 Var
   Size : SizeInt;
+  cp: TSystemCodePage;
 begin
   result:='';
   Size:=Length(S2);
   if Size>0 then
-    widestringmanager.Ansi2UnicodeMoveProc(PChar(S2),StringCodePage(S2),result,Size);
+  begin
+    cp:=StringCodePage(S2);
+    if cp=$ffff then
+      cp:=DefaultSystemCodePage;
+    widestringmanager.Ansi2UnicodeMoveProc(PChar(S2),cp,result,Size);
+  end;
 end;
 
 

+ 11 - 1
rtl/inc/wstrings.inc

@@ -267,11 +267,21 @@ Function fpc_WideStr_To_AnsiStr (const S2 : WideString{$ifdef FPC_HAS_CPSTRING};
 }
 Var
   Size : SizeInt;
+{$ifndef FPC_HAS_CPSTRING}
+  cp : TSystemCodePage;
+{$endif FPC_HAS_CPSTRING}
 begin
+{$ifndef FPC_HAS_CPSTRING}
+  cp:=$ffff;
+{$endif FPC_HAS_CPSTRING}
   result:='';
   Size:=Length(S2);
   if Size>0 then
-    widestringmanager.Wide2AnsiMoveProc(PWideChar(Pointer(S2)),result,{$ifdef FPC_HAS_CPSTRING}cp{$else}TSystemCodePage(0){$endif FPC_HAS_CPSTRING},Size);
+  begin
+    if cp=$ffff then
+      cp:=DefaultSystemCodePage;
+    widestringmanager.Wide2AnsiMoveProc(PWideChar(Pointer(S2)),result,cp,Size);
+  end;
 end;