Here is a POSIX[1] shell script that can print the code point and the character in a nice and easy way with the help of fc-match which is mentioned in Neil Mayhew's answer (it can even handle up to 8-hex-digit Unicode):
#!/bin/bash
for range in $(fc-match --format='%{charset}\n' "$1"); do
for n in $(seq "0x${range%-*}" "0x${range#*-}"); do
n_hex=$(printf "%04x" "$n")
# using \U for 5-hex-digits
printf "%-5s\U$n_hex\t" "$n_hex"
count=$((count + 1))
if [ $((count % 10)) = 0 ]; then
printf "\n"
fi
done
done
printf "\n"
You can pass the font name or anything that fc-match accepts:
$ ls-chars "DejaVu Sans"
Updated content:
I learned that subshell is very time consuming (the printf subshell in my script). So I managed to write a improved version that is 5-10 times faster!
#!/bin/bash
for range in $(fc-match --format='%{charset}\n' "$1"); do
for n in $(seq "0x${range%-*}" "0x${range#*-}"); do
printf "%04x\n" "$n"
done
done | while read -r n_hex; do
count=$((count + 1))
printf "%-5s\U$n_hex\t" "$n_hex"
[ $((count % 10)) = 0 ] && printf "\n"
done
printf "\n"
Old version:
$ time ls-chars "DejaVu Sans" | wc
592 11269 52740
real 0m2.876s
user 0m2.203s
sys 0m0.888s
New version (the line number indicates 5910+ characters, in 0.4 seconds!):
$ time ls-chars "DejaVu Sans" | wc
592 11269 52740
real 0m0.399s
user 0m0.446s
sys 0m0.120s
End of update
Sample output (it aligns better in my st terminal ๐):
0020 0021 ! 0022 " 0023 # 0024 $ 0025 % 0026 & 0027 ' 0028 ( 0029 )
002a * 002b + 002c , 002d - 002e . 002f / 0030 0 0031 1 0032 2 0033 3
0034 4 0035 5 0036 6 0037 7 0038 8 0039 9 003a : 003b ; 003c < 003d =
003e > 003f ? 0040 @ 0041 A 0042 B 0043 C 0044 D 0045 E 0046 F 0047 G
...
1f61a๐ 1f61b๐ 1f61c๐ 1f61d๐ 1f61e๐ 1f61f๐ 1f620๐ 1f621๐ก 1f622๐ข 1f623๐ฃ
1f625๐ฅ 1f626๐ฆ 1f627๐ง 1f628๐จ 1f629๐ฉ 1f62a๐ช 1f62b๐ซ 1f62d๐ญ 1f62e๐ฎ 1f62f๐ฏ
1f630๐ฐ 1f631๐ฑ 1f632๐ฒ 1f633๐ณ 1f634๐ด 1f635๐ต 1f636๐ถ 1f637๐ท 1f638๐ธ 1f639๐น
1f63a๐บ 1f63b๐ป 1f63c๐ผ 1f63d๐ฝ 1f63e๐พ 1f63f๐ฟ 1f640๐ 1f643๐
[1] Seems \U in printf is not POSIX standard?
fc-list :charset=1234, but double-check its outputโฆ (it does work for me, it shows Gentium as having 2082 but not 2161) - mirabilos