From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LBoPW-0001A7-L8 for qemu-devel@nongnu.org; Sun, 14 Dec 2008 05:41:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LBoPV-00019h-LO for qemu-devel@nongnu.org; Sun, 14 Dec 2008 05:41:18 -0500 Received: from [199.232.76.173] (port=36645 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LBoPV-00019Y-Ad for qemu-devel@nongnu.org; Sun, 14 Dec 2008 05:41:17 -0500 Received: from mail-bw0-f12.google.com ([209.85.218.12]:59635) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LBoPU-0000nq-PG for qemu-devel@nongnu.org; Sun, 14 Dec 2008 05:41:17 -0500 Received: by bwz5 with SMTP id 5so3590424bwz.10 for ; Sun, 14 Dec 2008 02:41:11 -0800 (PST) Message-ID: Date: Sun, 14 Dec 2008 12:41:11 +0200 From: "Blue Swirl" Subject: Re: [Qemu-devel] [6023] Use a hex value instead of possibly ambiguous 8 bit character In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Johannes Schindelin Cc: qemu-devel@nongnu.org On 12/14/08, Johannes Schindelin wrote: > Hi, > > > On Sun, 14 Dec 2008, Blue Swirl wrote: > > > Revision: 6023 > > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6023 > > Author: blueswir1 > > Date: 2008-12-14 09:30:41 +0000 (Sun, 14 Dec 2008) > > > > Log Message: > > ----------- > > Use a hex value instead of possibly ambiguous 8 bit character > > > /me is curious: how could buffer[j] = '\xb0' be ambiguous when buffer is > of type char *? It's not as if C did UTF-8 conversion with chars. The diff does not show it properly, there was a 8 bit character between the apostrophes, not \xb0. One day some compiler might want to parse the source text as UTF-8, then byte B0 and apostrophe after it could decode to something different with mysterious side effects. 0xb0 will not ever cause these problems, '\xb0' could work too. > Besides... > > > > @@ -1249,7 +1249,7 @@ > > unsigned char* c=(unsigned char*)direntry; > > int i; > > for(i=1;i<11 && c[i] && c[i]!=0xff;i+=2) > > -#define ADD_CHAR(c) {buffer[j] = (c); if (buffer[j] < ' ') buffer[j] = '\xB0'; j++;} > > +#define ADD_CHAR(c) {buffer[j] = (c); if (buffer[j] < ' ') buffer[j] = 0xb0; j++;} > > > in the meantime I think it would be more readable as > > #define ADD_CHAR(c) buffer[j++] = (c) < ' ' ? '\xb0' : 'c'; > > Note that > > - this code is only ever reached when DEBUG is defined, and > > - this code still assumes that your terminal is ISO-8859-1, which is > typically wrong these days (UTF-8 is the de-facto standard). Patches welcome :)