Re: [xml] isoLat1toUTF8 conv error - FYI
- From: Remy HAREL <rharel ext rd francetelecom com>
- To: Remy HAREL <rharel ext rd francetelecom com>
- Cc: "William M. Brack" <wbrack mmm com hk>, xml gnome org, veillard redhat com
- Subject: Re: [xml] isoLat1toUTF8 conv error - FYI
- Date: Thu, 26 May 2005 12:02:12 +0200
Hi list,
In fact, the problem was due to a memset which was not large enough.
When the isolat1ToUtf8 function tried to convert it, it read more than I
wanted, and of course the pointer did not contain isolat1 datas, so it
failed.
Instead of malloc and memset, I use now a calloc(), and everything's
allright. My mistake...
Regards
_____________________________________________
Remy HAREL - Teamlog |
____________________________________________|
Linux registered user #224740 |
France Telecom Recherche & Developpement |
____________________________________________|
__________________@ http://www.chezrem.org @|
Remy HAREL wrote:
Thank you very much. There was some mistakes in the code, you and
Daniel found it. It's right that I could have read more carefully the
documentation before posting this mail.
Regards,
_____________________________________________
Remy HAREL - Teamlog |
____________________________________________|
Linux registered user #224740 |
France Telecom Recherche & Developpement |
____________________________________________| __________________@
http://www.chezrem.org @|
William M. Brack wrote:
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
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]