[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnu-libiconv] iconv segfaults when converting shift-jis string
From: |
Bruno Haible |
Subject: |
Re: [bug-gnu-libiconv] iconv segfaults when converting shift-jis string to utf-8 |
Date: |
Wed, 21 Mar 2012 22:42:26 +0100 |
User-agent: |
KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; ) |
Hi,
Jordan Bradley wrote:
> (gdb) backtrace
> #0 0x6601193b in libiconv (icd=0xffffffff, inbuf=0x28ff04,
> inbytesleft=0x28fee0, outbuf=0x28fee4, outbytesleft=0x28fedc)
> at ./iconv.c:254
icd = (iconv_t) (-1) is not a valid conversion descriptor.
You must check the return value of the iconv_open() function.
You need to read the specifications of the iconv_open() and iconv() functions:
http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.13/iconv_open.3.html
http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.13/iconv.3.html
in particular the sections "RETURN VALUE" and "ERRORS".
> This is what I have so far so that I can figure out how
> to use iconv properly: http://pastebin.com/z7Zgs8LA
It is not that easy to use iconv() correctly. If you want to convert
an entire string, you can use the convenience functions contained in the
'extras' directory of the GNU libiconv source distribution:
http://git.savannah.gnu.org/gitweb/?p=libiconv.git;a=tree;f=extras;hb=HEAD
Bruno