diff options
Diffstat (limited to 'packages/iconvenc/src/iconvert.inc')
-rw-r--r-- | packages/iconvenc/src/iconvert.inc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/iconvenc/src/iconvert.inc b/packages/iconvenc/src/iconvert.inc index d4428a8cf6..61ced52f6c 100644 --- a/packages/iconvenc/src/iconvert.inc +++ b/packages/iconvenc/src/iconvert.inc @@ -14,7 +14,7 @@ var iconvres: size_t; begin H := iconv_open(PChar(ToEncoding), PChar(FromEncoding)); - if not assigned(H) then + if h=Iconv_t(-1) then begin Res := S; exit(-1); @@ -48,7 +48,8 @@ begin Dst:=PChar(Res)+Offset; OutLen:=Length(Res)-Offset; end; - iconvres:=iconv(H, nil, nil, @Dst, @Outlen); + InLen=0; + iconvres:=iconv(H, nil, @InLen, @Dst, @Outlen); if iconvres = size_t(-1) then begin res:=s; @@ -91,7 +92,8 @@ begin SetLength(Res, Length(Res)+InLen*2+5); // 5 is minimally one utf-8 char Dst:=PChar(Res)+Offset; OutLen:=Length(Res)-Offset; - iconv(H, nil, nil, @Dst, @Outlen); + InLen:=0; + iconv(H, nil, @InLen, @Dst, @Outlen); end; {$endif} // trim output buffer @@ -101,7 +103,8 @@ begin SetLength(Res, Length(Res)+InLen*2+5); // 5 is minimally one utf-8 char Dst:=PChar(Res)+Offset; OutLen:=Length(Res)-Offset; - iconvres:=iconv(H, nil, nil, @Dst, @Outlen); + InLen:=0; + iconvres:=iconv(H, nil, @InLen, @Dst, @Outlen); setlength(Res,Length(Res) - Outlen); iconv_close(H); end; |