merge r17587 from cpstrnew branch by inoussa:

fpc_AnsiStr_To_AnsiStr : avoid code page conversion when possible.

git-svn-id: trunk@19120 -
This commit is contained in:
paul 2011-09-17 13:59:38 +00:00
parent 1d2778af24
commit 7c21524892

View File

@ -416,11 +416,25 @@ Var
Size : SizeInt;
temp : UnicodeString;
begin
temp:=S;
result:='';
Size:=Length(temp);
Size:=Length(S);
if Size>0 then
widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Pointer(temp)),result,cp,Size);
begin
if (cp=0) then
cp:=DefaultSystemCodePage;
if (StringCodePage(S)=cp) then
begin
SetLength(result,Size);
Move(S[1],result[1],Size);
PAnsiRec(Pointer(S)-AnsiFirstOff)^.CodePage:=cp;
end
else
begin
temp:=S;
Size:=Length(temp);
widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Pointer(temp)),result,cp,Size);
end;
end;
end;
Function fpc_AnsiStr_To_AnsiStr (const S : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; [external name 'FPC_ANSISTR_TO_ANSISTR'];