From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27570 invoked from network); 4 Mar 2008 09:40:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Mar 2008 09:40:41 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 18181 invoked from network); 4 Mar 2008 09:40:34 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Mar 2008 09:40:34 -0000 Received: (qmail 27416 invoked by alias); 4 Mar 2008 09:40:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24678 Received: (qmail 27400 invoked from network); 4 Mar 2008 09:40:28 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 4 Mar 2008 09:40:28 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 083EE8028C53 for ; Tue, 4 Mar 2008 10:40:21 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly10d.srv.mailcontrol.com (MailControl) with ESMTP id m249eCqg011325 for ; Tue, 4 Mar 2008 09:40:17 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 4 Mar 2008 09:40:08 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m249e8TY012520 for ; Tue, 4 Mar 2008 09:40:08 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m249e7DC012517 for ; Tue, 4 Mar 2008 09:40:08 GMT Message-Id: <200803040940.m249e7DC012517@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: printf %s in UTF-8 is not POSIX-compliant In-reply-to: <20080304012917.GA15833@prunille.vinc17.org> References: <20080304012917.GA15833@prunille.vinc17.org> Comments: In-reply-to Vincent Lefevre message dated "Tue, 04 Mar 2008 02:29:17 +0100." Date: Tue, 04 Mar 2008 09:40:07 +0000 From: Peter Stephenson X-OriginalArrivalTime: 04 Mar 2008 09:40:08.0292 (UTC) FILETIME=[BBD8DA40:01C87DDB] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.68.0.120 X-Virus-Scanned: ClamAV 0.91.2/6122/Tue Mar 4 09:14:01 2008 on bifrost X-Virus-Status: Clean Vincent Lefevre wrote: > Under UTF-8 locales: > > vin:~> zsh-beta -f > vin% emulate sh > vin% printf ".%2s.\n" é > . é. > vin% /usr/bin/printf ".%2s.\n" é > .é. > vin% > > As you can see, the zsh printf builtin doesn't behave like the > coreutils printf, and this is zsh which is wrong. Indeed, the > precision is the number of bytes, not the number of characters. That seems to me useless. I can understand in C that a string is a low-level entity consisting of a set of bytes, but I don't see why a shell should force the user to count the size of a multibyte character in the particular locale. You can fix it by unsetting the MULTIBYTE option. printf() { emulate -L zsh; unsetopt multibyte; builtin printf "$@" } -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070