From owner-freebsd-questions@FreeBSD.ORG Mon Jan 26 22:25:15 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 692D5106566C for ; Mon, 26 Jan 2009 22:25:15 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out3.apple.com (mail-out3.apple.com [17.254.13.22]) by mx1.freebsd.org (Postfix) with ESMTP id 2345D8FC14 for ; Mon, 26 Jan 2009 22:25:15 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay11.apple.com (relay11.apple.com [17.128.113.48]) by mail-out3.apple.com (Postfix) with ESMTP id 194384EC76BB; Mon, 26 Jan 2009 14:25:15 -0800 (PST) Received: from relay11.apple.com (unknown [127.0.0.1]) by relay11.apple.com (Symantec Brightmail Gateway) with ESMTP id F295128084; Mon, 26 Jan 2009 14:25:14 -0800 (PST) X-AuditID: 11807130-a4889bb000000fcd-ce-497e384a755f Received: from cswiger1.apple.com (cswiger1.apple.com [17.227.140.124]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by relay11.apple.com (Apple SCV relay) with ESMTP id D57BD2807E; Mon, 26 Jan 2009 14:25:14 -0800 (PST) Message-Id: <0B02CEE8-D38A-4D94-B76D-49721BDDACF0@mac.com> From: Chuck Swiger To: Svein Halvor Halvorsen In-Reply-To: <497E31EE.9010202@lvor.halvorsen.cc> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Mon, 26 Jan 2009 14:25:14 -0800 References: <497E31EE.9010202@lvor.halvorsen.cc> X-Mailer: Apple Mail (2.930.3) X-Brightmail-Tracker: AAAAAA== Cc: questions@freebsd.org Subject: Re: printf and utf-8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2009 22:25:15 -0000 On Jan 26, 2009, at 1:58 PM, Svein Halvor Halvorsen wrote: > As far as I can see, printf is not calculating strings lengths > correctly when using utf-8 encoding. Either that, or I'm using byte > count, and can't find the character count :-/ printf(1) explicitly states that it works with ASCII and ANSI X3.159-1989 (``ANSI C89'') character escapes, and it also notes: Multibyte characters are not recognized in format strings (this is only a problem if `%' can appear inside a multibyte character). Some platforms have a printf_l(3) which is locale/xlocale-aware, but there doesn't seem to be a corresponding CLI utility which understands Unicode/UTF8/widechars. Regards, -- -Chuck