vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm using an HP-UX release B.11.11 U 9000/800 969017836. The iconv(3C) function seems to be returning EINVAL when I expect it to return EILSEQ. Specifically, when I run #include <iconv.h> #include <stdio.h> #include <errno.h> #include <assert.h> int main(void) { char inbuf[3] = "\200\333", outbuf[32], *in = inbuf, *out = outbuf; size_t n, insize = 2, outsize = sizeof outbuf; iconv_t context = iconv_open("roman8", "utf8"); assert(context != (iconv_t)-1); n = iconv(context, &in, &insize, &out, &outsize); printf("result %d, errno %d: %s (EILSEQ %d, EINVAL %d)\n", (int)n, errno, strerror(errno), EILSEQ, EINVAL); iconv_close(context); return 0; } it prints result -1, errno 22: Invalid argument (EILSEQ 47, EINVAL 22). Nothing else I've fed it has convinced the UTF-8 converter to return EILSEQ. Am I mistaken in my expectations about iconv's errno semantics? And if this is a known bug, which patchlevel do I need to get to to fix it? [Why is the difference at all interesting? I'm converting a stream of multibyte characters. EINVAL is normally iconv's way of saying "hey, there's half a multibyte character at the end of this buffer, give me more input before I can finish converting this"--not an error at all. In contrast, EILSEQ requires the character conversion equivalent of a Heimlich maneuver if one continues at all--remove all or parts of the offending character, reset the conversion state, emit a placeholder on the output side.] Thanks!, Jutta Degener <jutta@pobox.com> |