On Mon, 11 Aug 2008, Chris Young wrote:

On Mon, 11 Aug 2008 19:01:09 +0100 (BST), John-Mark Bell wrote:

Well the only way for that to return NULL would be encountering
UTF8_CONVERT_NOMEM or for the input parameters to be bad (namely item and
charset being NULL). Given the gdb output above, it's clearly the charset
conversion that's causing problems. I've still insufficient details to
know why, though.

Some further investigation, and it appears that this is where it is
returning UTF8_CONVERT_NOMEM:

utf8.c line 304 /* no match, so create a new cd */
cd = iconv_open(to, from);
if (cd == (iconv_t)-1) {
if (errno == EINVAL)
return UTF8_CONVERT_BADENC;
/* default to no memory */
return UTF8_CONVERT_NOMEM;  <<<<<<<<

I can't get the actual value of errno though.

You'll be able to LOG(()) it, at least. However, the man page for iconv_open states the following:

  EINVAL The conversion from fromcode to tocode is not supported by the
         implementation.

so I'd expect it to actually return what the documentation says.

Here's a standalone testcase you can try:

#include <errno.h>
#include <iconv.h>
#include <stdio.h>
#include <string.h>

int main(void)
{
        iconv_t cd = iconv_open("UTF-8", "ISO-8859-1//TRANSLIT");

        if (cd == (iconv_t) -1) {
                printf("Failed, errno == %d (%s)\n",
                                errno, strerror(errno));
        } else {
                printf("Success\n");
        }

        iconv_close(cd);

        return 0;
}


J.

Reply via email to