From owner-freebsd-current@FreeBSD.ORG Mon Sep 12 00:53:55 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 157B51065670 for ; Mon, 12 Sep 2011 00:53:55 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id E992B8FC13 for ; Mon, 12 Sep 2011 00:53:54 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id p8C0ci0T069270 for freebsd-current@freebsd.org; Mon, 12 Sep 2011 00:38:44 GMT (envelope-from kientzle@freebsd.org) Received: from [192.168.2.119] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id e3jnzvuiuurkd2ru6vah7jqtmi; for freebsd-current@freebsd.org; Mon, 12 Sep 2011 00:38:44 +0000 (UTC) (envelope-from kientzle@freebsd.org) From: Tim Kientzle Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 11 Sep 2011 17:38:44 -0700 Message-Id: To: FreeBSD-current Current Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) Subject: iconv not reporting errors? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2011 00:53:55 -0000 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 #include #include 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); }