Utf8

De Linuxmemo.

(Différences entre les versions)
(Table Utf8)
(Utile)
Ligne 36 : Ligne 36 :
==Utile==
==Utile==
 +
\x... pour les code en hexa
 +
\u... pour les code en utf8
 +
*retour chariot est le charactère "\u240D"  
*retour chariot est le charactère "\u240D"  
*tabulation est \x09 ou \u0009
*tabulation est \x09 ou \u0009

Version du 23 avril 2013 à 15:03

Sommaire

Code dans Vim

For instance, in the vim text-editor you would enter insert mode and press CTRL+VU and then the code-point number as a 4-digit hexadecimal number (pad with zeros if necessary). So you would type

CTRL+V. U 2 6 2 0.

Code dans le Shell

At a terminal running Bash you would type CTRL+SHIFT+U and type in the hexadecimal code-point of the character you want. During input your cursor should show an underlined u. The first non-digit you type ends input, and renders the character. So you could be able to print U+2620 in Bash using the following:

echo CTRL+SHIFT+U2620ENTERENTER

(The first enter ends Unicode input, the second runs the echo command)

Code avec echo

In UTF-8 it's actually 6 digit (or 3 byte).

$ echo -e "\xE2\x98\xA0"
☠

To check how it's encoded by you console, you can use hexdump. echo -n ☠ | hexdump

Code avec printf

  • via printf
printf '\xc3\xa0'
  • via le shell :
printf $'\xc3\xa0'
  • idem en ksh (88/93) :
typeset -i8 a=16#c3 b=16#a0
print “\${a#8\#}\${b#8\#}”

Table Utf8

http://www.utf8-chartable.de/

Utile

\x... pour les code en hexa
\u... pour les code en utf8

  • retour chariot est le charactère "\u240D"
  • tabulation est \x09 ou \u0009
Outils personnels