From owner-freebsd-standards@FreeBSD.ORG Sun Jul 15 08:00:15 2007 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D14916A402 for ; Sun, 15 Jul 2007 08:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 34D1713C4AA for ; Sun, 15 Jul 2007 08:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l6F80FW7026612 for ; Sun, 15 Jul 2007 08:00:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l6F80FWt026610; Sun, 15 Jul 2007 08:00:15 GMT (envelope-from gnats) Date: Sun, 15 Jul 2007 08:00:15 GMT Message-Id: <200707150800.l6F80FWt026610@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Christoph Mallon Cc: Subject: Re: kern/114578: [libc] wide character printing using swprintf(dst, n, "%ls", txt) fails depending on LC_CTYPE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Christoph Mallon List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2007 08:00:15 -0000 The following reply was made to PR kern/114578; it has been noted by GNATS. From: Christoph Mallon To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/114578: [libc] wide character printing using swprintf(dst, n, "%ls", txt) fails depending on LC_CTYPE Date: Sun, 15 Jul 2007 09:58:18 +0200 Here is a simplified example: #include #include #include static const wchar_t txt[] = { 0x41C, 0x43D, 0x440, 0 }; // "Mir" in cyrillic int main(void) { wchar_t str[4]; int ret; setlocale(LC_CTYPE, "C"); ret = swprintf(str, sizeof(str) / sizeof(*str), txt); printf("%d\n", ret); return 0; } Only a format string is used here. The call to swprintf() fails here, too, and -1 is returned. The POSIX standard (and ANSI C99, too, though with slightly different wording) say this: "The format is composed of zero or more directives: ordinary wide-characters, which are simply copied to the output stream" (from http://www.opengroup.org/onlinepubs/009695399/functions/swprintf.html , section DESCRIPTION, second clause). So even copying the ordinary wide-characters from the format string fails.