merge r13486 from cpstrnew branch by florian:

+ fpc_ansistr_to_ansistr implemented, rtl compiles again

git-svn-id: trunk@19084 -
This commit is contained in:
paul 2011-09-17 11:03:30 +00:00
parent ae0d732c8f
commit 06af8f3e44
3 changed files with 24 additions and 1 deletions

View File

@ -2878,7 +2878,13 @@ implementation
end
{ encoding parameter required? }
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,
ccallparanode.create(cordconstnode.create(tstringdef(resultdef).encoding,u16inttype,true),
ccallparanode.create(left,nil)),resultdef)

View File

@ -336,6 +336,22 @@ end;
{$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}
{ the following declaration has exactly the same effect as }

View File

@ -266,6 +266,7 @@ function fpc_AnsiStr_To_ShortStr (high_of_res: SizeInt;const S2 : Ansistring): s
{$else FPC_STRTOSHORTSTRINGPROC}
procedure fpc_AnsiStr_To_ShortStr (out res : shortstring;const S2 : Ansistring); compilerproc;
{$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_Char_To_AnsiStr(const c : Char): AnsiString; compilerproc;