Re: [xml] isoLat1toUTF8 conv error
- From: "William M. Brack" <wbrack mmm com hk>
- To: veillard redhat com
- Cc: HEINECKE Johannes RD-TECH-LAN <johannes heinecke francetelecom com>, xml gnome org
- Subject: Re: [xml] isoLat1toUTF8 conv error
- Date: Wed, 25 May 2005 00:06:20 +0800 (HKT)
Daniel Veillard said:
On Tue, May 24, 2005 at 12:20:52PM +0200, Remy HAREL wrote:
...
isolat1ToUTF8(texte_tmp, &outlen, ( const unsigned char*)texte, &inlen);
...
Not checking the value returned by the function, bad :-(
Incomplete non-compilable code, bad :-(
And outlen and inlen are both IN and OUT parameters.
outlen seems initialized to 0. Did you used a debugger to check what
was the content of the buffer after the call ? If no please do !
I would appreciate if you didn't posted as if the code was in error and
provide fully contained examples which pass compilation with gcc -Wall
without warnings. isolat1ToUTF8 is exactly like an iconv function except
it has no context parameter since the conversion is stateless.
Daniel
Just a small follow-up in case someone searches the mailing list on encoding
conversion - there are (at least) two errors in the posted code which will
cause it to fail.
First, the parameter to malloc is just not right - technically it should be
2*strlen(texte) + 1 [you had an indirection (*) before the strlen, and didn't
include the string terminator]. Even better would be 2*inlen + 1 (since you
have already done the strlen for that variable).
Second, as Daniel pointed out, the isolat1ToUTF8 parameter "outlen" is *both*
and IN (input) and an OUT (output) parameter. Before calling isolat1ToUTF8 it
must be set to the length of the output buffer. Because it is set to zero, no
conversion is taking place, and no data is being placed in the output buffer.
HTH
Bill
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]