4

I have a string and want to know of which Unicode characters it consists. Character name and code point is sufficient.

A solution must be FLOSS and run natively on GNU/Linux.

The command-line tool unicode can do this, but the display of the results is not easy to parse visually, as the characters are displayed inbetween each character’s metadata block:

"Oh, hai" result of unicode

The web app http://rishida.net/uniview/ has a better presentation, as you can read your original string (although vertical) next to the result, without having to skip metadata lines:

"Oh, hai" result of UniView

Which tool has a better result presentation?

Ideally it would be a GUI where the input string is shown horizontally, non-visual characters get marked somehow, and clicking on a character shows its name and metadata. But I’m open for other solutions; I’d even be happy with an UniView-like display, if there is a local client using somethimg similar.

2

You can easily change the presentation by piping the output of unicode into a bit of text rewriting. To get the same presentation as the UniView web app:

unicode -s 'Oh, hai' |
perl -000 -ne '/^U+(.*)\n.*\n(.)/ and print "$2 $1\n"'

Alternatively, you could type your text in an editor with good editor support. For example, in Emacs, press C-u C-x = (command what-cursor-position with a prefix argument) to show a lot of information about the character under the cursor, including its Unicode code point, name and properties.

2

You can get more or less what you need using python and its unicodedata module - something like:

import unicodedata as ucd
u = u'The UK uses £ but Japan ¥'
for c in u:
    print c, "%04x" % ord(c), ucd.category(c), ucd.name(c)

produces:

T 0054 Lu LATIN CAPITAL LETTER T
h 0068 Ll LATIN SMALL LETTER H
e 0065 Ll LATIN SMALL LETTER E
  0020 Zs SPACE
U 0055 Lu LATIN CAPITAL LETTER U
K 004b Lu LATIN CAPITAL LETTER K
  0020 Zs SPACE
u 0075 Ll LATIN SMALL LETTER U
s 0073 Ll LATIN SMALL LETTER S
e 0065 Ll LATIN SMALL LETTER E
s 0073 Ll LATIN SMALL LETTER S
  0020 Zs SPACE
£ 00a3 Sc POUND SIGN
  0020 Zs SPACE
b 0062 Ll LATIN SMALL LETTER B
u 0075 Ll LATIN SMALL LETTER U
t 0074 Ll LATIN SMALL LETTER T
  0020 Zs SPACE
J 004a Lu LATIN CAPITAL LETTER J
a 0061 Ll LATIN SMALL LETTER A
p 0070 Ll LATIN SMALL LETTER P
a 0061 Ll LATIN SMALL LETTER A
n 006e Ll LATIN SMALL LETTER N
  0020 Zs SPACE
¥ 00a5 Sc YEN SIGN

You could also output your input first and easily, (using sets), only output one line for each distinct character which might be even more use.

  • Free
  • Already installed on most Linux distros
  • If you need a GUI, or html output, you could knock one up quite quickly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.