View Full Version : printf unicode
July 24th, 2008, 03:21 PM
executing this command:
printf "\u0041" > /pippo
I found in pippo file \u0041, when I attempt an "A"
executing the command:
printf "\x41" > /pippo
In pippo file I found an "A" (correct!)
July 24th, 2008, 03:27 PM
Because hex 0x41 is an 'A' in ASCII (dec 65)... AFAIK, Unicode inherits the same hex codes for the old ASCII characters.
July 24th, 2008, 03:34 PM
ok, but how do I write an "A" with unicode format and printf command?
July 24th, 2008, 03:52 PM
The issue lies in that we actually have two different printf:
1. GNU bash's built-in printf, which doesn't seem to support Unicode.
2. /usr/bin/printf, which is what you want.
But, /usr/bin/printf seem to print characters that are exclusively Unicode? So ASCII characters should be printed with "\x"?
ugi@UGI:~$ /usr/bin/printf "\u0041"
/usr/bin/printf: el nombre de carácter universal \u0041 es inválido
("Invalid universal character name \u0041"... loosely translated)
ugi@UGI:~$ /usr/bin/printf "\u0141\n"
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.