mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 01:11:07 +02:00
LCL: catching exception for conversion try
git-svn-id: trunk@14920 -
This commit is contained in:
parent
e254c10254
commit
be047c5015
@ -4196,23 +4196,23 @@ 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]);
|
||||
SL:=TStringList.Create;
|
||||
SL.Text:=s;
|
||||
FN1:=GetTempFileName;
|
||||
SL.SaveToFile(FN1);
|
||||
FN2:=GetTempFileName;
|
||||
fpSystem('iconv -f '+FromEncoding+' -t '+ToEncoding+' '+FN1+' >'+FN2);
|
||||
SL.LoadFromFile(FN2);
|
||||
if SL.Text<>'' then
|
||||
Result:=SL.Text
|
||||
else
|
||||
Result:=s;
|
||||
DeleteFile(FN1);
|
||||
DeleteFile(FN2);
|
||||
{$else}
|
||||
Result:=s;
|
||||
try
|
||||
SL:=TStringList.Create;
|
||||
SL.Text:=s;
|
||||
FN1:=GetTempFileName;
|
||||
SL.SaveToFile(FN1);
|
||||
FN2:=GetTempFileName;
|
||||
fpSystem('iconv -f '+FromEncoding+' -t '+ToEncoding+' '+FN1+' >'+FN2);
|
||||
SL.LoadFromFile(FN2);
|
||||
if SL.Text<>'' then
|
||||
Result:=SL.Text;
|
||||
DeleteFile(FN1);
|
||||
DeleteFile(FN2);
|
||||
except
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user