mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 20:19:16 +02:00
LCL: added default conversion for unix function using iconv, from Whitewind, bug #11203
git-svn-id: trunk@15866 -
This commit is contained in:
parent
5f699ac8b2
commit
c2b2c2b47a
@ -27,7 +27,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Classes, dos, LCLProc
|
SysUtils, Classes, dos, LCLProc
|
||||||
{$IFDEF UNIX},unix{$ENDIF};
|
{$IFDEF UNIX},{$IFDEF VER2_3}iconvenc{$ELSE}unix{$ENDIF}{$ENDIF};
|
||||||
|
|
||||||
{$inline on}
|
{$inline on}
|
||||||
|
|
||||||
@ -4538,9 +4538,13 @@ var
|
|||||||
AFrom, ATo, SysEnc : String;
|
AFrom, ATo, SysEnc : String;
|
||||||
Encoded : Boolean;
|
Encoded : Boolean;
|
||||||
{$ifdef Unix}
|
{$ifdef Unix}
|
||||||
|
{$ifdef VER2_3}
|
||||||
|
Dummy: String;
|
||||||
|
{$else}
|
||||||
SL: TStringList;
|
SL: TStringList;
|
||||||
FN1, FN2: String;
|
FN1, FN2: String;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
AFrom:=NormalizeEncoding(FromEncoding);
|
AFrom:=NormalizeEncoding(FromEncoding);
|
||||||
ATo:=NormalizeEncoding(ToEncoding);
|
ATo:=NormalizeEncoding(ToEncoding);
|
||||||
@ -4723,11 +4727,22 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Stupid code. Works anyway, but extra-slow
|
|
||||||
Result:=s;
|
Result:=s;
|
||||||
{$ifdef Unix}
|
{$ifdef Unix}
|
||||||
DebugLn(['CPConvert NOTE: using slow iconv workaround to convert from ',AFrom,' to ',ATo]);
|
|
||||||
try
|
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:=TStringList.Create;
|
||||||
SL.Text:=s;
|
SL.Text:=s;
|
||||||
FN1:=GetTempFileName;
|
FN1:=GetTempFileName;
|
||||||
@ -4739,6 +4754,7 @@ begin
|
|||||||
Result:=SL.Text;
|
Result:=SL.Text;
|
||||||
DeleteFile(FN1);
|
DeleteFile(FN1);
|
||||||
DeleteFile(FN2);
|
DeleteFile(FN2);
|
||||||
|
{$endif}
|
||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
Loading…
Reference in New Issue
Block a user