Explorar el Código

merge r13486 from cpstrnew branch by florian:
+ fpc_ansistr_to_ansistr implemented, rtl compiles again

git-svn-id: trunk@19084 -

paul hace 14 años
padre
commit
06af8f3e44
Se han modificado 3 ficheros con 24 adiciones y 1 borrados
  1. 7 1
      compiler/ncnv.pas
  2. 16 0
      rtl/inc/astrings.inc
  3. 1 0
      rtl/inc/compproc.inc

+ 7 - 1
compiler/ncnv.pas

@@ -2878,7 +2878,13 @@ implementation
           end
           end
         { encoding parameter required? }
         { encoding parameter required? }
         else if (tstringdef(resultdef).stringtype=st_ansistring) and
         else if (tstringdef(resultdef).stringtype=st_ansistring) and
-            (tstringdef(left.resultdef).stringtype in [st_widestring,st_unicodestring]) then
+            ((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)
+             )
+            ) then
             result:=ccallnode.createinternres(procname,
             result:=ccallnode.createinternres(procname,
               ccallparanode.create(cordconstnode.create(tstringdef(resultdef).encoding,u16inttype,true),
               ccallparanode.create(cordconstnode.create(tstringdef(resultdef).encoding,u16inttype,true),
               ccallparanode.create(left,nil)),resultdef)
               ccallparanode.create(left,nil)),resultdef)

+ 16 - 0
rtl/inc/astrings.inc

@@ -336,6 +336,22 @@ end;
 {$endif EXTRAANSISHORT}
 {$endif EXTRAANSISHORT}
 
 
 
 
+Function fpc_AnsiStr_To_AnsiStr (const S : AnsiString;cp : TSystemCodePage): AnsiString; compilerproc;
+{
+  Converts an AnsiString to an AnsiString taking code pages into care
+}
+Var
+  Size : SizeInt;
+  temp : UnicodeString;
+begin
+  temp:=S;
+  result:='';
+  Size:=Length(temp);
+  if Size>0 then
+    widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Pointer(temp)),result,cp,Size);
+end;
+
+
 {$ifndef FPC_STRTOSHORTSTRINGPROC}
 {$ifndef FPC_STRTOSHORTSTRINGPROC}
 
 
 { the following declaration has exactly the same effect as                   }
 { the following declaration has exactly the same effect as                   }

+ 1 - 0
rtl/inc/compproc.inc

@@ -266,6 +266,7 @@ function fpc_AnsiStr_To_ShortStr (high_of_res: SizeInt;const S2 : Ansistring): s
 {$else FPC_STRTOSHORTSTRINGPROC}
 {$else FPC_STRTOSHORTSTRINGPROC}
 procedure fpc_AnsiStr_To_ShortStr (out res : shortstring;const S2 : Ansistring); compilerproc;
 procedure fpc_AnsiStr_To_ShortStr (out res : shortstring;const S2 : Ansistring); compilerproc;
 {$endif FPC_STRTOSHORTSTRINGPROC}
 {$endif FPC_STRTOSHORTSTRINGPROC}
+Function fpc_AnsiStr_To_AnsiStr (const S : AnsiString;cp : TSystemCodePage): AnsiString; compilerproc;
 Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; compilerproc;
 Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; compilerproc;
 Function fpc_Char_To_AnsiStr(const c : Char): AnsiString; compilerproc;
 Function fpc_Char_To_AnsiStr(const c : Char): AnsiString; compilerproc;