bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BUG? RFE? printf lacking unicode support in multiple areas


From: Greg Wooledge
Subject: Re: BUG? RFE? printf lacking unicode support in multiple areas
Date: Fri, 20 May 2011 08:23:44 -0400
User-agent: Mutt/1.4.2.3i

On Fri, May 20, 2011 at 12:31:31AM -0700, Linda Walsh wrote:
> 1) use of of the \uXXXX and \UXXXXXXXX escape sequences
> in the format string (16 and 32 bit Unicode values).

This isn't even a sentence.  What bash command did you execute, and
what did it do, and what did you expect it to do?

In bash 4.2, on a Debian 6.0 box with a UTF-8 locale, printf '\u203c\n'
prints the !! character (and a newline).  You have not actually stated
what you DID, and how it FAILED.

> 2) It doesn't handle the "%lc" conversion to print out wide
> characters.  To demonstrate this I created a wide char for a
> double exclamation mark U+203C, using a=$'0x3c\0x20' and then
> tried to print "$a".

What does   a=$'...'; printf '%s\n' "$a"   have to do with %lc?

Even if you had correctly used the $'...' syntax, $'\x3c\x20' is NOT
how you encode U+203C.  Nor does it have anything to do with %lc,
whatever that is.  (I don't see it defined in POSIX
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html
for instance.)

According to http://www.fileformat.info/info/unicode/char/203c/index.htm
the UTF-8 encoding of U+203C is E2 80 BC.  Thus:

wooledg@wooledg:/var/tmp/bash/bash-4.2$ a=$'\xe2\x80\xbc'; printf '%s\n' "$a"
?

Here the ? is the !! character being pasted across machines into my
vim window where I'm writing this email.  But trust me, it worked.

> The gnu version of printf handles the \uXXXX and \UXXXXXXXX
> version, but doesn't appear to handle the "%lc" format specifier.

What's that got to do with bash?  What does \u have to do with %lc?

> I.e. /usr/bin/printf "\u203c" will print out the double exclamation mark
> on a tty that is using a font with it defined (like "Lucida Console").

As I said above, bash 4.2's printf *also* handles this correctly.  What
did you do, and how did it fail?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]