看板 FB_current 關於我們 聯絡資訊
I'm trying to use the iconv that's in FreeBSD-CURRENT and it's not = reporting errors the way I expect. To demonstrate, here's a test = program that tries to convert UTF-8 to KOI8-R. This should report an = error, since the UTF-8 string here "=C4=90=C3=92=C3=89=C3=97=C3=85=C3=94" = contains characters not available in KOI8-R. On FreeBSD-CURRENT (updated yesterday), the iconv() call returns 0, = consumes the entire input, and generates 9 characters "D`O'ExA^O". I = believe that the call should return 6 in this case, since each of the = six input characters were converted to "non-identical" characters in the = output. The term "non-identical" is used in the return value description of: http://pubs.opengroup.org/onlinepubs/007908799/xsh/iconv.html For comparison, I tried this on MacOS, where the iconv() call returns = -1, consumes no input, and generates no output. #include <iconv.h> #include <stdio.h> #include <string.h> int main(int argc, char **argv) { const char *input =3D = "\303\220\303\222\303\211\303\227\303\205\303\224"; const char *in =3D input; size_t insize =3D strlen(in); char outbuff[64]; char *out =3D outbuff; size_t outsize =3D sizeof(outbuff); iconv_t cd =3D iconv_open("KOI8-R", "UTF-8"); size_t s =3D iconv(cd, &in, &insize, &out, &outsize); *out =3D '\0'; printf("s =3D %d\n", (int)s); printf("insize =3D %d\n", (int)insize); printf("outsize =3D %d\n", (int)outsize); printf("%s", outbuff); return (0); } _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"