diff options
author | paul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-09-17 13:59:38 +0000 |
---|---|---|
committer | paul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-09-17 13:59:38 +0000 |
commit | e72651040caf4928f0fc3fe6e7b38e916b348c50 (patch) | |
tree | 3422fb188df14deebcb023942c8151fff7eb62af /rtl/inc/astrings.inc | |
parent | 9872dbfaf59d15f859d9421490ee1e67bdcd09dd (diff) | |
download | fpc-e72651040caf4928f0fc3fe6e7b38e916b348c50.tar.gz |
merge r17587 from cpstrnew branch by inoussa:
fpc_AnsiStr_To_AnsiStr : avoid code page conversion when possible.
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@19120 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl/inc/astrings.inc')
-rw-r--r-- | rtl/inc/astrings.inc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index 04152bb474..8ac759dc71 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -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']; |