268

I'd like to add the Unicode skull and crossbones to my shell prompt (specifically the 'SKULL AND CROSSBONES' (U+2620)), but I can't figure out the magic incantation to make echo spit it, or any other, 4-digit Unicode character. Two-digit one's are easy. For example, echo -e "\x55", .

In addition to the answers below it should be noted that, obviously, your terminal needs to support Unicode for the output to be what you expect. gnome-terminal does a good job of this, but it isn't necessarily turned on by default.

On macOS's Terminal app Go to Preferences-> Encodings and choose Unicode (UTF-8).

Yuri
  • 4,254
  • 1
  • 29
  • 46
masukomi
  • 10,313
  • 10
  • 40
  • 49
  • 7
    Note that your *"2 digit one's are easy (to echo)"* comment is only valid for values up to `"\x7F"` in a UTF-8 locale (which the `bash` tag suggests yours is)... patterns represented by a **single byte** are never in the range`\x80-\xFF`. This range is illegal in singl-byte UTF-8 chars. eg a Unicode Codepoint value of `U+0080` (ie. `\x80`) is actually 2 bytes in UTF-8.. `\xC2\x80`.. – Peter.O Dec 02 '11 at 05:51
  • 5
    E.g. `printf "\\u007C\\u001C"`. – kenorb Apr 10 '16 at 04:11
  • **NB:** for me in `gnome-terminal`, `echo -e '\ufc'` does not produce a ü, even with character encoding set to UTF-8. However, eg `urxvt` does print eg `printf "\\ub07C\\ub01C"` as expected (not with a � or box). – isomorphismes Mar 11 '17 at 19:51
  • @Peter.O Why is the `bash` tag such a useful hint? Are different terminals common in CJK or … ? – isomorphismes Mar 11 '17 at 19:54
  • 2
    @Peter.O zsh, fish, scsh, elvish, etc... there are many different shells, each can handle unicode characters however they want (or not). "bash" makes it clear this question isn't about some weird shell that does things differently. – masukomi Jul 22 '17 at 17:47
  • `while read -r line; do echo -e "$line"; done` – kenorb Nov 24 '22 at 22:41

19 Answers19

281

In UTF-8 it's actually 6 digits (or 3 bytes).

$ printf '\xE2\x98\xA0'
☠

To check how it's encoded by the console, use hexdump:

$ printf ☠ | hexdump
0000000 98e2 00a0                              
0000003
Flimm
  • 136,138
  • 45
  • 251
  • 267
vartec
  • 131,205
  • 36
  • 218
  • 244
  • 6
    Mine outputs "���" instead of ☠... Why is that? – trusktr Sep 29 '12 at 04:14
  • 2
    @trusktr: you're not using UTF-8 terminal – vartec Sep 29 '12 at 08:02
  • 8
    That's true. I discovered i was using `LANG=C` instead of `LANG=en_US.UTF-8`. Now my terminals in Gnome show the symbols properly... The real terminals (tty1-6) still don't though. – trusktr Oct 03 '12 at 00:09
  • 6
    For those people trying a hexdump: `0000000 f0 9f 8d ba` translates to `\xf0\x9f\x8d\xba`. Example echo: `echo -e "\xf0\x9f\x8d\xba"`. – Blaise May 28 '15 at 14:25
  • 12
    You can also use the `$'...'` syntax to get the encoded character in to a variable without using a `$(...)` capturing subshell, for use in contexts that don't themselves interpret the escape sequences: `skull=$'\xE2\x98\xA0'` – Andrew Janke Jul 05 '15 at 05:14
  • @trusktr: `LANG=C` affects how the encoding is interpreted. When you use that, `"\xE2\x98\xA0"` gets interpreted as 3 high-range ASCII characters, instead of a single Unicode character composed of 3 code points. As for the "real" terminals (you mean virtual console TTYs, not actual hardware terminals, right?), maybe they're just using a font that doesn't have the ☠ glyph? They usually have pretty simple bitmap fonts. – Andrew Janke Jul 05 '15 at 05:16
  • 7
    Another thing about hexdump: on my machine, the second command in the answer outputs `0000000 98e2 00a0`. Of course the `0000000` is just an unimportant offset, but the bytes after it translate to `\xe2\x98\xa0`, because the machine uses the little endian byte order. – sigalor May 15 '16 at 18:07
  • 2
    If your bash can output that characters below, goto: http://unicode-table.com/en/#2591 And just copy it paste to your script, have fun. – nobjta_9x_tq Aug 24 '16 at 03:41
  • I edited the answer from `printf "\xE2\x98\xA0"` to `printf '\xE2\x98\xA0'`. The result is the same, but it's an easier answer to understand, as you don't have to think about whether the shell is interpreting `\x` or not. – Flimm Jan 04 '18 at 11:00
  • 1
    If you want to avoid endian order confusion, pipe to `xxd` instead of `hexdump`. Output is then, `00000000: e298 a0` (same byte order as you entered). `xxd` is typically provided on Linux with `vim`. On macOS, it appears to come out-of-the-box (as does `vim`). – boweeb Apr 20 '20 at 14:29
170
% echo -e '\u2620'     # \u takes four hexadecimal digits
☠
% echo -e '\U0001f602' # \U takes eight hexadecimal digits

This works in Zsh (I've checked version 4.3) and in Bash 4.2 or newer.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
Juliano
  • 39,173
  • 13
  • 67
  • 73
75

So long as your text-editors can cope with Unicode (presumably encoded in UTF-8) you can enter the Unicode code-point directly.

For instance, in the Vim text-editor you would enter insert mode and press Ctrl + V + U 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. See: What is the easiest way to insert Unicode characters into a document?

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, and the second runs the echo command.)

Credit: Ask Ubuntu SE

Community
  • 1
  • 1
RobM
  • 8,373
  • 3
  • 45
  • 37
  • 2
    A good source for the hexademical code points is http://unicodelookup.com/#0x2620/1 – RobM Aug 25 '12 at 12:10
  • 1
    The version of vim I'm using (7.2.411 on RHEL 6.3) doesn't respond as desired when there's a dot between the ctrl-v and the u, but works fine when that dot is omitted. – Chris Johnson Feb 15 '13 at 20:28
  • @ChrisJohnson: I've removed the period from the instructions, it was not intended to be a key press (which is why it didn't appear with the keyboard effect). Sorry for the confusion. – RobM Jul 27 '13 at 10:45
  • 6
    Beware: this works in a terminal running Bash only if you're running it **under GTK+** environment, as Gnome. – n.r. Feb 25 '14 at 21:37
  • 2
    The ability to `C-S-u 2 6 2 0` is a feature of your terminal emulator, X Input Method (XIM), or similar. AFAIK, you will be unable to send both `SHIFT` and `CTRL` to the terminal layer. The terminal only speaks in characters, rather than in keysyms and keycodes like your X server (also, its is 7-bit for all intents and purposes). In this world, `CTRL` masks the 4 most significant bits (& 0b00001111) which results in – nabin-info Jun 04 '17 at 02:51
  • In vim, it is not `ctrl` + `v` + `u` all at once. It is rather `ctrl-v` and _then_ `u`. Lowercase `u` for at most four hex digits (example 03bb, λ), uppercase `U` for 8 hex digits (example 0001f4a9, ). – Fernando Basso Sep 24 '19 at 11:12
37

Here's a fully internal Bash implementation, no forking, unlimited size of Unicode characters.

fast_chr() {
    local __octal
    local __char
    printf -v __octal '%03o' $1
    printf -v __char \\$__octal
    REPLY=$__char
}

function unichr {
    local c=$1    # Ordinal of char
    local l=0    # Byte ctr
    local o=63    # Ceiling
    local p=128    # Accum. bits
    local s=''    # Output string

    (( c < 0x80 )) && { fast_chr "$c"; echo -n "$REPLY"; return; }

    while (( c > o )); do
        fast_chr $(( t = 0x80 | c & 0x3f ))
        s="$REPLY$s"
        (( c >>= 6, l++, p += o+1, o>>=1 ))
    done

    fast_chr $(( t = p | c ))
    echo -n "$REPLY$s"
}

## test harness
for (( i=0x2500; i<0x2600; i++ )); do
    unichr $i
done

Output was:

─━│┃┄┅┆┇┈┉┊┋┌┍┎┏
┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟
┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯
┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿
╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏
═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟
╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯
╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿
▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏
▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯
▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿
◀◁◂◃◄◅◆◇◈◉◊○◌◍◎●
◐◑◒◓◔◕◖◗◘◙◚◛◜◝◞◟
◠◡◢◣◤◥◦◧◨◩◪◫◬◭◮◯
◰◱◲◳◴◵◶◷◸◹◺◻◼◽◾◿
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Orwellophile
  • 13,235
  • 3
  • 69
  • 45
  • I'm very curious the reasoning behind the round-about method, and the specific use of the REPLY variable. I am assuming you inspected bash source or ran through or something to optimize, which I can see how your choices could be optimizing, albeit highly dependent on the interpreter). – nabin-info Jun 01 '17 at 17:05
  • @nabin-info `$REPLY` is a wrong chocie is this case, Using small caps for variable name could be prefered in order to avoid mis interpretation. You could test to replace `sed 's/REPLY/anyVarname/g'` , script will work fine anyway. – F. Hauri - Give Up GitHub Jun 04 '23 at 10:35
  • `$REPLY` is the default output variable for the inbuilt `read` command. This solution doesn't use the `read` command, but `$REPLY` is as good as any name. It is my observation that all-caps variable names in bash scripts often indicate 'external' thing, whether they be configuration options/globals, environment variables, or returns from other commands or functions. Lowercase variables tend to be used locally. This is purely my opinion, and you can use any variable name you like. – Orwellophile Jun 07 '23 at 10:30
26

Quick one-liner to convert UTF-8 characters into their 3-byte format:

var="$(echo -n '☠' | od -An -tx1)"; printf '\\x%s' ${var^^}; echo

or

echo -n '☠' | od -An -tx1 | sed 's/ /\\x/g'  

The output of both is \xE2\x98\xA0, so you can write reversely:

echo $'\xe2\x98\xa0'   # ☠
Yuri
  • 4,254
  • 1
  • 29
  • 46
David King
  • 1
  • 2
  • 2
  • 6
    I wouldn't call the above example *quick* (with 11 commands and their params)... Also it only handles 3 byte UTF-8 chars` (UTF-8 chars can be 1, 2, or 3 bytes)... This is a bit shorter and works for 1-3++++ bytes: `printf "\\\x%s" $(printf '☠'|xxd -p -c1 -u)` .... *xxd* is shipped as part of the 'vim-common' package – Peter.O Dec 02 '11 at 17:01
  • PS: I just noticed that the above hexdump/awk example is swithching the sequence of bytes in a byte-pair. This **does not** apply to a UTF-8 dump. It would be relavent if it were a dump of UTF-16LE and wanted to output Unicode **Codepoints**, but it doesn't make sense here as the input is UTF-8 and the output is exactly as input (plus the \x before each hexdigit-pair) – Peter.O Dec 02 '11 at 17:35
  • 8
    UTF-8 characters can be 1 - 4 bytes sequences – cms Apr 12 '13 at 19:33
  • 1
    based on the comment of @Peter.O, I find the following, while bigger, pretty handy: `hexFromGlyph(){ if [ "$1" == "-n" ]; then outputSeparator=' '; shift; else outputSeparator='\n'; fi for glyph in "$@"; do printf "\\\x%s" $(printf "$glyph"|xxd -p -c1 -u); echo -n -e "$outputSeparator"; done } # usage: $ hexFromGlyph ☠ ✿ \xE2\x98\xA0 \xE2\x9C\xBF $ hexFromGlyph -n ☠ ✿ \xE2\x98\xA0 \xE2\x9C\xBF` – StephaneAG Oct 10 '15 at 00:04
  • 6
    Good god man. Consider: `codepoints () { printf 'U+%04x\n' ${@/#/\'} ; } ; codepoints A R ☯ z` ... enjoy – nabin-info Jun 01 '17 at 17:40
  • @nabin-info Great, I was just to ask, how I could get the utf-16 representation, and that is it, your codepoints function does it. Thank you. – erik Sep 09 '21 at 10:58
  • The quickest approach of all: Paste your emoji into the bash prompt and hit enter. Result: `bash: $'\342\230\240': command not found` – Bryan Roach Jul 13 '23 at 22:25
14

Just put "☠" in your shell script. In the correct locale and on a Unicode-enabled console it'll print just fine:

$ echo ☠
☠
$

An ugly "workaround" would be to output the UTF-8 sequence, but that also depends on the encoding used:

$ echo -e '\xE2\x98\xA0'
☠
$
Flimm
  • 136,138
  • 45
  • 251
  • 267
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
12

Here is a list of all unicode emoji's available:

https://en.wikipedia.org/wiki/Emoji#Unicode_blocks

Example:

echo -e "\U1F304"

For get the ASCII value of this character use hexdump

echo -e "" | hexdump -C

00000000  f0 9f 8c 84 0a                                    |.....|
00000005

And then use the values informed in hex format

echo -e "\xF0\x9F\x8C\x84\x0A"

Matheus
  • 41
  • 1
  • 5
10

In bash to print a Unicode character to output use \x,\u or \U (first for 2 digit hex, second for 4 digit hex, third for any length)

echo -e '\U1f602'

I you want to assign it to a variable use $'...' syntax

x=$'\U1f602'
echo $x
user2622016
  • 6,060
  • 3
  • 32
  • 53
9

Any of these three commands will print the character you want in a console, provided the console do accept UTF-8 characters (most current ones do):

echo -e "SKULL AND CROSSBONES (U+2620) \U02620"
echo $'SKULL AND CROSSBONES (U+2620) \U02620'
printf "%b" "SKULL AND CROSSBONES (U+2620) \U02620\n"

SKULL AND CROSSBONES (U+2620) ☠

After, you could copy and paste the actual glyph (image, character) to any (UTF-8 enabled) text editor.

If you need to see how such Unicode Code Point is encoded in UTF-8, use xxd (much better hex viewer than od):

echo $'(U+2620) \U02620' | xxd
0000000: 2855 2b32 3632 3029 20e2 98a0 0a         (U+2620) ....

That means that the UTF8 encoding is: e2 98 a0

Or, in HEX to avoid errors: 0xE2 0x98 0xA0. That is, the values between the space (HEX 20) and the Line-Feed (Hex 0A).

If you want a deep dive into converting numbers to chars: look here to see an article from Greg's wiki (BashFAQ) about ASCII encoding in Bash!

mazunki
  • 682
  • 5
  • 17
  • re:"Or, in HEX to avoid errors..." I hardly think that converting a unicode char to some binary encoding that you express in hex chars, **helps** avoid errors. Using the unicode notation in "bash" would better avoid errors i.e.: " \uHHHH---the Unicode (ISO/IEC 10646) character whose value is the ----hexadecimal value HHHH (one to four hex digits); \UHHHHHHHH ----the Unicode (ISO/IEC 10646) character whose value is the ----hexadecimal value HHHHHHHH (one to eight hex digits) – Astara Feb 04 '16 at 03:56
7

I'm using this:

$ echo -e '\u2620'
☠

This is pretty easier than searching a hex representation... I'm using this in my shell scripts. That works on gnome-term and urxvt AFAIK.

Flimm
  • 136,138
  • 45
  • 251
  • 267
Metal3d
  • 2,905
  • 1
  • 23
  • 29
  • 2
    @masukomi if you know how to use brew you can install a more recent bash and use that. The above works fine on my mac terminal when using the upgraded bash. – mcheema Jan 11 '14 at 12:12
  • Yes, that's fine with newer versions of bash. Hower prompt strings, e.g $PS1 don't use echo escape formats – cms Oct 28 '14 at 18:03
6

You may need to encode the code point as octal in order for prompt expansion to correctly decode it.

U+2620 encoded as UTF-8 is E2 98 A0.

So in Bash,

export PS1="\342\230\240"

will make your shell prompt into skull and bones.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
cms
  • 5,864
  • 2
  • 28
  • 31
6

If you don't mind a Perl one-liner:

$ perl -CS -E 'say "\x{2620}"'
☠

-CS enables UTF-8 decoding on input and UTF-8 encoding on output. -E evaluates the next argument as Perl, with modern features like say enabled. If you don't want a newline at the end, use print instead of say.

Flimm
  • 136,138
  • 45
  • 251
  • 267
5

Sorry for reviving this old question. But when using bash there is a very easy approach to create Unicode codepoints from plain ASCII input, which even does not fork at all:

unicode() { local -n a="$1"; local c; printf -vc '\\U%08x' "$2"; printf -va "$c"; }
unicodes() { local a c; for a; do printf -vc '\\U%08x' "$a"; printf "$c"; done; };

Use it as follows to define certain codepoints

unicode crossbones 0x2620
echo "$crossbones"

or to dump the first 65536 unicode codepoints to stdout (takes less than 2s on my machine. The additional space is to prevent certain characters to flow into each other due to shell's monospace font):

for a in {0..65535}; do unicodes "$a"; printf ' '; done

or to tell a little very typical parent's story (this needs Unicode 2010):

unicodes 0x1F6BC 32 43 32 0x1F62D 32 32 43 32 0x1F37C 32 61 32 0x263A 32 32 43 32 0x1F4A9 10

Explanation:

  • printf '\UXXXXXXXX' prints out any Unicode character
  • printf '\\U%08x' number prints \UXXXXXXXX with the number converted to Hex, this then is fed to another printf to actually print out the Unicode character
  • printf recognizes octal (0oct), hex (0xHEX) and decimal (0 or numbers starting with 1 to 9) as numbers, so you can choose whichever representation fits best
  • printf -v var .. gathers the output of printf into a variable, without fork (which tremendously speeds up things)
  • local variable is there to not pollute the global namespace
  • local -n var=other aliases var to other, such that assignment to var alters other. One interesting part here is, that var is part of the local namespace, while other is part of the global namespace.
    • Please note that there is no such thing as local or global namespace in bash. Variables are kept in the environment, and such are always global. Local just puts away the current value and restores it when the function is left again. Other functions called from within the function with local will still see the "local" value. This is a fundamentally different concept than all the normal scoping rules found in other languages (and what bash does is very powerful but can lead to errors if you are a programmer who is not aware of that).
Tino
  • 9,583
  • 5
  • 55
  • 60
  • well -- doesn't work at all for me. any attempt to use any of your functions, emits: line 6: local: -n: invalid option local: usage: local name[=value] ... I'm using latest (10.14.2) MacOS and bash (GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)) – Motti Shneor Mar 26 '19 at 08:42
5

In Bash:

UnicodePointToUtf8()
{
    local x="$1"               # ok if '0x2620'
    x=${x/\\u/0x}              # '\u2620' -> '0x2620'
    x=${x/U+/0x}; x=${x/u+/0x} # 'U-2620' -> '0x2620'
    x=$((x)) # from hex to decimal
    local y=$x n=0
    [ $x -ge 0 ] || return 1
    while [ $y -gt 0 ]; do y=$((y>>1)); n=$((n+1)); done
    if [ $n -le 7 ]; then       # 7
        y=$x
    elif [ $n -le 11 ]; then    # 5+6
        y=" $(( ((x>> 6)&0x1F)+0xC0 )) \
            $(( (x&0x3F)+0x80 ))" 
    elif [ $n -le 16 ]; then    # 4+6+6
        y=" $(( ((x>>12)&0x0F)+0xE0 )) \
            $(( ((x>> 6)&0x3F)+0x80 )) \
            $(( (x&0x3F)+0x80 ))"
    else                        # 3+6+6+6
        y=" $(( ((x>>18)&0x07)+0xF0 )) \
            $(( ((x>>12)&0x3F)+0x80 )) \
            $(( ((x>> 6)&0x3F)+0x80 )) \
            $(( (x&0x3F)+0x80 ))"
    fi
    printf -v y '\\x%x' $y
    echo -n -e $y
}

# test
for (( i=0x2500; i<0x2600; i++ )); do
    UnicodePointToUtf8 $i
    [ "$(( i+1 & 0x1f ))" != 0 ] || echo ""
done
x='U+2620'
echo "$x -> $(UnicodePointToUtf8 $x)"

Output:

─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟
┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿
╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟
╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿
▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿
◀◁◂◃◄◅◆◇◈◉◊○◌◍◎●◐◑◒◓◔◕◖◗◘◙◚◛◜◝◞◟
◠◡◢◣◤◥◦◧◨◩◪◫◬◭◮◯◰◱◲◳◴◵◶◷◸◹◺◻◼◽◾◿
U+2620 -> ☠
Dmitry
  • 664
  • 8
  • 8
4

The printf builtin (just as the coreutils' printf) knows the \u escape sequence which accepts 4-digit Unicode characters:

   \uHHHH Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)

Test with Bash 4.2.37(1):

$ printf '\u2620\n'
☠
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Michael Jaros
  • 4,586
  • 1
  • 22
  • 39
  • printf is also a shell built-in. You're probably using the default macOS bash (v3). Try with `\printf` to use the standalone executable, or try with upgraded bash – mcint Aug 29 '18 at 20:21
3

Based on Stack Overflow questions Unix cut, remove first token and https://stackoverflow.com/a/15903654/781312:

(octal=$(echo -n ☠ | od -t o1 | head -1 | cut -d' ' -f2- | sed -e 's#\([0-9]\+\) *#\\0\1#g')
echo Octal representation is following $octal
echo -e "$octal")

Output is the following.

Octal representation is following \0342\0230\0240
☠
Community
  • 1
  • 1
test30
  • 3,496
  • 34
  • 26
3

Upgrade 2023...

From some time ago, use %b in printf:

printf %b\\n \\U1F600

So you could assign a variable by using -v flag of 's printf builtin:

printf -v smiley \\U1F600
echo $smiley 

Then for showing quickly some part of unicode table:

printf %b\\n \\U1F6{{0..9},{A..F}}{{0..9},{a..f}}|paste -d\  -{,,,}{,,,}
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               

Showing braille part:

printf %b\\n \\U28{{0..9},{A..F}}{{0..9},{a..f}}|paste -d\  -{,,,}{,,,}
⠀ ⠁ ⠂ ⠃ ⠄ ⠅ ⠆ ⠇ ⠈ ⠉ ⠊ ⠋ ⠌ ⠍ ⠎ ⠏
⠐ ⠑ ⠒ ⠓ ⠔ ⠕ ⠖ ⠗ ⠘ ⠙ ⠚ ⠛ ⠜ ⠝ ⠞ ⠟
⠠ ⠡ ⠢ ⠣ ⠤ ⠥ ⠦ ⠧ ⠨ ⠩ ⠪ ⠫ ⠬ ⠭ ⠮ ⠯
⠰ ⠱ ⠲ ⠳ ⠴ ⠵ ⠶ ⠷ ⠸ ⠹ ⠺ ⠻ ⠼ ⠽ ⠾ ⠿
⡀ ⡁ ⡂ ⡃ ⡄ ⡅ ⡆ ⡇ ⡈ ⡉ ⡊ ⡋ ⡌ ⡍ ⡎ ⡏
⡐ ⡑ ⡒ ⡓ ⡔ ⡕ ⡖ ⡗ ⡘ ⡙ ⡚ ⡛ ⡜ ⡝ ⡞ ⡟
⡠ ⡡ ⡢ ⡣ ⡤ ⡥ ⡦ ⡧ ⡨ ⡩ ⡪ ⡫ ⡬ ⡭ ⡮ ⡯
⡰ ⡱ ⡲ ⡳ ⡴ ⡵ ⡶ ⡷ ⡸ ⡹ ⡺ ⡻ ⡼ ⡽ ⡾ ⡿
⢀ ⢁ ⢂ ⢃ ⢄ ⢅ ⢆ ⢇ ⢈ ⢉ ⢊ ⢋ ⢌ ⢍ ⢎ ⢏
⢐ ⢑ ⢒ ⢓ ⢔ ⢕ ⢖ ⢗ ⢘ ⢙ ⢚ ⢛ ⢜ ⢝ ⢞ ⢟
⢠ ⢡ ⢢ ⢣ ⢤ ⢥ ⢦ ⢧ ⢨ ⢩ ⢪ ⢫ ⢬ ⢭ ⢮ ⢯
⢰ ⢱ ⢲ ⢳ ⢴ ⢵ ⢶ ⢷ ⢸ ⢹ ⢺ ⢻ ⢼ ⢽ ⢾ ⢿
⣀ ⣁ ⣂ ⣃ ⣄ ⣅ ⣆ ⣇ ⣈ ⣉ ⣊ ⣋ ⣌ ⣍ ⣎ ⣏
⣐ ⣑ ⣒ ⣓ ⣔ ⣕ ⣖ ⣗ ⣘ ⣙ ⣚ ⣛ ⣜ ⣝ ⣞ ⣟
⣠ ⣡ ⣢ ⣣ ⣤ ⣥ ⣦ ⣧ ⣨ ⣩ ⣪ ⣫ ⣬ ⣭ ⣮ ⣯
⣰ ⣱ ⣲ ⣳ ⣴ ⣵ ⣶ ⣷ ⣸ ⣹ ⣺ ⣻ ⣼ ⣽ ⣾ ⣿

Better into a little function

showU8_256() { 
    local i a
    for a ;do
        for i in {0..9} {A..F}; do
            printf '\\U%05Xx: %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b\n' \
                0x$a$i \\U$a${i}{{0..9},{A..F}}
        done
    done
}

Then

showU8_256 1f{3,4}
\U01F30x:                
\U01F31x:                
\U01F32x:                
\U01F33x:                
\U01F34x:                
\U01F35x:                
\U01F36x:                
\U01F37x:                
\U01F38x:                
\U01F39x:                
\U01F3Ax:                
\U01F3Bx:                
\U01F3Cx:                
\U01F3Dx:                
\U01F3Ex:                
\U01F3Fx:                
\U01F40x:                
\U01F41x:                
\U01F42x:                
\U01F43x:                
\U01F44x:                
\U01F45x:                
\U01F46x:                
\U01F47x:                
\U01F48x:                
\U01F49x:                
\U01F4Ax:                
\U01F4Bx:                
\U01F4Cx:                
\U01F4Dx:                
\U01F4Ex:                
\U01F4Fx:                

Browsing unicode table

For this, after searching reliable way, I'v finally posted on SuperUser Dumping / browsing full unicode table, my dumpUnicode script:

./dumpUnicode | grep SMIL.*SUNGLAS\\\|FONDUE
\U01F60E: '' SMILING FACE WITH SUNGLASSES
\U01FAD5: '' FONDUE
F. Hauri - Give Up GitHub
  • 64,122
  • 17
  • 116
  • 137
2

Easy with a Python2/3 one-liner:

$ python -c 'print u"\u2620"'    # python2
$ python3 -c 'print(u"\u2620")'  # python3

Results in:

not2qubit
  • 14,531
  • 8
  • 95
  • 135
Chris Johnson
  • 20,650
  • 6
  • 81
  • 80
1

If hex value of unicode character is known

H="2620"
printf "%b" "\u$H"

If the decimal value of a unicode character is known

declare -i U=2*4096+6*256+2*16
printf -vH "%x" $U              # convert to hex
printf "%b" "\u$H"
philcolbourn
  • 4,042
  • 3
  • 28
  • 33