Compiled support for the whole UTF8 symbols by their names
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
test
.gitignore
README.md
mix.exs
mix.lock

README.md

StringNaming

Compile-time generated set of modules to ease an access to a predefined subset of UTF8 symbols.

Installation

def deps do
  [{:string_naming, "~> 0.3"}]
end

Warning

The initial compilation of the module in the default configuration takes ≈ 10 sec.

The compilation of the whole UTF8 symbol set requires ≈ 10 min.

config/confix.exs

The configuration of what is to be compiled could be changed accordingly to what might be found in default config. Basically, leading '#' and '=' in front of group names are treated as comments.

How it works

The code parses the NamesList.txt file provided by Consortium. It builds the set of nested modules under StringNaming. Each nested module is granted with __all__/0 function that returns all the available symbols in that particular namespace.

iex|1StringNaming.AnimalSymbols.__all__
[ant: "🐜", bat: "🦇", bird: "🐦", blowfish: "🐡", boar: "🐗",
 bug: "🐛", butterfly: "🦋", cat: "🐈", chicken: "🐔", chipmunk: "🐿",
 cow: "🐄", crab: "🦀", crocodile: "🐊", deer: "🦌", dog: "🐕",
 dolphin: "🐬", dragon: "🐉", duck: "🦆", eagle: "🦅", elephant: "🐘",
 fish: "🐟", goat: "🐐", gorilla: "🦍", honeybee: "🐝", horse: "🐎",
 koala: "🐨", leopard: "🐆", lizard: "🦎", monkey: "🐒", mouse: "🐁",
 octopus: "🐙", owl: "🦉", ox: "🐂", penguin: "🐧", pig: "🐖",
 poodle: "🐩", rabbit: "🐇", ram: "🐏", rat: "🐀", rhinoceros: "🦏",
 rooster: "🐓", scorpion: "🦂", shark: "🦈", sheep: "🐑",
 shrimp: "🦐", snail: "🐌", snake: "🐍", spider: "🕷", squid: "🦑",
 tiger: "🐅", ...]
iex|2StringNaming.AnimalSymbols.monkey
"🐒"

Changelog

0.4.0

Added StringNaming.graphemes/1 function that receives a regular expression and returns the list of matched characters:

iex> StringNaming.graphemes ~r/\Aspace/i
[
  space_medium_mathematical_space: "",
  spaces_em_quad: "",
  spaces_em_space: "",
  spaces_en_quad: " ",
  spaces_en_space: "",
  spaces_figure_space: "",
  spaces_four_per_em_space: "",
  spaces_hair_space: "",
  spaces_punctuation_space: "",
  spaces_six_per_em_space: "",
  spaces_thin_space: "",
  spaces_three_per_em_space: ""
]

Is it of any good?

Sure it is.


Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/string_naming.