View Full Version : printf unicode
kamel81
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!)
Any suggestion?
thanks,
Alex
nvteighen
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.
kamel81
July 24th, 2008, 03:34 PM
ok, but how do I write an "A" with unicode format and printf command?
thanks :)
nvteighen
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)
This works:
ugi@UGI:~$ /usr/bin/printf "\u0141\n"
Ł
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.