Skip to content

mgumz/ucn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Unicode Names

Small utility to print Unicode symbol names. The main reference is https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt.

Usage

$> ucn [FLAGS] [CP...]

Prints Unicode symbols to Stdout. All processing remains local, no external service is triggered. Any non-flag argument provided is used to filter the built in code points.

Flags

-ofmt.alfred
    use special JSON format ready to be used in http://alfredapp.com
-ofmt.etab (default)
    use Elastic Tabstops (default)
-ofmt.json
    use JSON to print the symbols
-ofmt.tsv
    use tab-separated values

-source value
    data source: unicode, nerdfont, all (default: all)

-limit value
    limit results to <value> symbols

-filter.fuzzy value
    fuzzy filter all symbol names for <value>
-filter.partial value
    filter all symbol names for a partial match on <value>
-filter.starts-with value
    filter all symbol names for the ones which starts-with <value>

-reverse value
    reverse list of symbols

-license 
    print license information and exit
-v 
    print version and exit

The filter flags -filter.*, -limit and -reverse can be given multiple times: they are applied in the order they are provided. See Examples down below.

The output format flags -ofmt.* can be given multiple times: the last one given wins.

Output Formats

The -ofmt.* flags define the output format for the (filtered) Unicode symbols.

Elastic Tabstops

Print (filtered) Unicode symbols as properly aligned text by using the Elastic Tabstop algorithm, see http://nickgravgaard.com/elastictabstops/index.html for more information.

The columns are (in order):

TSV

Print (filtered) Unicode symbols as tab-separated values.

The columns are (in order):

JSON

Print (filtered) Unicode symbols as JSON.

[
  {
    "name": "MATHEMATICAL BOLD SMALL PI",
    "cp": "U+1D6D1",
    "html": "&#1d6d1;",
    "json": "\\u1d6d1",
    "symbol": "๐›‘",
    "www": "https://symbl.cc/en/1d6d1"
  },
  โ€ฆ
]

AlfredApp

AlfredApp is using the JSON formatted output to interactively render the results of a search to its UI. See also the #Extras section.

{
    "items": [
      {
        "title": "๐›‘ - MATHEMATICAL BOLD SMALL PI",
        "subtitle": "U+1D6D1 - &#1d6d1; - https://symbol.cc/en/1d6d1",
        "arg": "๐›‘",
        "variables": {
          "cp": "U+1D6D1",
          "html": "&#1d6d1;",
          "json": "\\u1d6d1",
          "symbol": "๐›‘",
          "www": "https://symbol.cc/en/1d6d1"
        }
      },
    ...

Examples

Search for the ๐›‘ symbol:

$> ucn -filter.partial math -filter.partial "pi" -limit 5

'๐šท'    1d6b7    U+1D6B7    &#1d6b7;    \\u1d6b7    MATHEMATICAL BOLD CAPITAL PI
'๐›‘'    1d6d1    U+1D6D1    &#1d6d1;    \\u1d6d1    MATHEMATICAL BOLD SMALL PI
'๐›ก'    1d6e1    U+1D6E1    &#1d6e1;    \\u1d6e1    MATHEMATICAL BOLD PI SYMBOL
'๐›ฑ'    1d6f1    U+1D6F1    &#1d6f1;    \\u1d6f1    MATHEMATICAL ITALIC CAPITAL PI
'๐œ‹'    1d70b    U+1D70B    &#1d70b;    \\u1d70b    MATHEMATICAL ITALIC SMALL PI

Print info about code point 1D6B7:

ucn 1D6D1
'๐›‘'    1d6d1    U+1D6D1    &#1d6d1;    \\u1d6d1    MATHEMATICAL BOLD SMALL PI

Search for "upward arrows":

$> ucn -filter.starts-with "upwards -filter.starts-with "arrow" -limit 5

''อŽ'    34e     U+034E    &#34e;          \\u34e     COMBINING UPWARDS ARROW BELOW
'โ†‘'    2191    U+2191    &UpArrow;       \\u2191    UPWARDS ARROW
'โ†Ÿ'    219f    U+219F    &Uarr;          \\u219f    UPWARDS TWO HEADED ARROW
'โ†ฅ'    21a5    U+21A5    &UpTeeArrow;    \\u21a5    UPWARDS ARROW FROM BAR
'โ†ฐ'    21b0    U+21B0    &Lsh;           \\u21b0    UPWARDS ARROW WITH TIP LEFTWARDS

Count the number of embedded Unicode symbols:

$>  ucn | wc -l
40074

Limit the available runes to the first 1000, then filter for "pi":

$> ucn -limit 1000 -filter.starts-with pi

'ยถ'    b6     U+00B6    &para;     \\ub6     PILCROW SIGN
'ฮ '    3a0    U+03A0    &Pi;       \\u3a0    GREEK CAPITAL LETTER PI
'ฯ€'    3c0    U+03C0    &pi;       \\u3c0    GREEK SMALL LETTER PI
'ฯ–'    3d6    U+03D6    &varpi;    \\u3d6    GREEK PI SYMBOL

First filter "pi" in all symbols, then limit the output to 1000 results:

$> ucn -filter.starts-with pi -limit 1000

'ยถ'         b6       U+00B6     &para;         \\ub6       PILCROW SIGN
'ฮ '         3a0      U+03A0     &Pi;           \\u3a0      GREEK CAPITAL LETTER PI
'ฯ€'         3c0      U+03C0     &pi;           \\u3c0      GREEK SMALL LETTER PI
'ฯ–'         3d6      U+03D6     &varpi;        \\u3d6      GREEK PI SYMBOL
'ี“'         553      U+0553     &#553;         \\u553      ARMENIAN CAPITAL LETTER PIWR
'ึƒ'         583      U+0583     &#583;         \\u583      ARMENIAN SMALL LETTER PIWR
...
'๐Ÿงฉ'         1f9e9    U+1F9E9    &#1f9e9;       \\u1f9e9    JIGSAW PUZZLE PIECE
'๐Ÿงท'         1f9f7    U+1F9F7    &#1f9f7;       \\u1f9f7    SAFETY PIN
'๐Ÿฉท'         1fa77    U+1FA77    &#1fa77;       \\u1fa77    PINK HEART
'๐Ÿช…'         1fa85    U+1FA85    &#1fa85;       \\u1fa85    PINATA
'๐Ÿชฎ'         1faae    U+1FAAE    &#1faae;       \\u1faae    HAIR PICK

186 entries in total

Extras

Nerd Fonts

In addition to the Unicode Character Database, ucn ships names for the glyphs bundled in Nerd Fonts. These live entirely in Unicode's Private Use Area and only render if a Nerd Font is installed on your host โ€” otherwise you'll see tofu (โ˜).

The -source flag selects which data set to list:

  • unicode โ€” only the UCD entries
  • nerdfont โ€” only the Nerd Fonts glyphs
  • all โ€” both (this is the default)

Example: search Nerd Fonts for github:

$> ucn -source nerdfont -filter.partial github -limit 5

'๎ช„'    ea84    U+EA84    &#ea84;    \\uea84    COD GITHUB
'๎ซฟ'    eaff    U+EAFF    &#eaff;    \\ueaff    COD GITHUB ACTION
'๎ฌ€'    eb00    U+EB00    &#eb00;    \\ueb00    COD GITHUB ALT
'๎ฎก'    eba1    U+EBA1    &#eba1;    \\ueba1    COD GITHUB INVERTED
'๎—ฝ'    e5fd    U+E5FD    &#e5fd;    \\ue5fd    CUSTOM FOLDER GITHUB

The glyph metadata is sourced from ryanoasis/nerd-fonts' glyphnames.json (MIT-licensed). The pinned upstream version lives in internal/pkg/nerdfont/data_gen.go; bumping it is an intentional act.

Alfred Workflow "Unicode Names"

Screenshot Alfred Workflow

Installation:

  1. Get AlfredApp + Powerpack - https://www.alfredapp.com
  2. Grab the Alfred-Workflow file (a .zip) from the releases page
  3. Import it into Alfred.
  4. Use it - the default triggers are uc and ucf (fuzzy)

Links

Related

About

Small utility to print unicode symbol names

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors