From c2b2c2b47aece717e22574b1eaf5dc0c4548953d Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 25 Jul 2008 15:53:41 +0000 Subject: [PATCH] LCL: added default conversion for unix function using iconv, from Whitewind, bug #11203 git-svn-id: trunk@15866 - --- lcl/lconvencoding.pas | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lcl/lconvencoding.pas b/lcl/lconvencoding.pas index 6dd1300ea3..2d4d450270 100644 --- a/lcl/lconvencoding.pas +++ b/lcl/lconvencoding.pas @@ -27,7 +27,7 @@ interface uses SysUtils, Classes, dos, LCLProc - {$IFDEF UNIX},unix{$ENDIF}; + {$IFDEF UNIX},{$IFDEF VER2_3}iconvenc{$ELSE}unix{$ENDIF}{$ENDIF}; {$inline on} @@ -4538,9 +4538,13 @@ var AFrom, ATo, SysEnc : String; Encoded : Boolean; {$ifdef Unix} + {$ifdef VER2_3} + Dummy: String; + {$else} SL: TStringList; FN1, FN2: String; {$endif} + {$endif} begin AFrom:=NormalizeEncoding(FromEncoding); ATo:=NormalizeEncoding(ToEncoding); @@ -4723,11 +4727,22 @@ begin end; - //Stupid code. Works anyway, but extra-slow Result:=s; {$ifdef Unix} - DebugLn(['CPConvert NOTE: using slow iconv workaround to convert from ',AFrom,' to ',ATo]); try + {$ifdef VER2_3} + if not IconvLibFound and not InitIconv(Dummy) then + begin + DebugLn(['Can not init iconv: ',Dummy]); + Exit; + end; + if Iconvert(s, Result, AFrom, ATo)<>0 then + begin + Result:=s; + Exit; + end; + {$else} + DebugLn(['CPConvert NOTE: using slow iconv workaround to convert from ',AFrom,' to ',ATo]); SL:=TStringList.Create; SL.Text:=s; FN1:=GetTempFileName; @@ -4739,6 +4754,7 @@ begin Result:=SL.Text; DeleteFile(FN1); DeleteFile(FN2); + {$endif} except end; {$endif}