Puid.CharSet (puid v1.1.2)

Pre-defined Puid.CharSets are specified via an atom charset option during Puid module definition.

Example

iex> defmodule(AlphanumId, do: use(Puid, charset: :alphanum))

Pre-defined CharSets

:alpha

Upper/lower case alphabet

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

:alpha_lower

Lower case alphabet

abcdefghijklmnopqrstuvwxyz

:alpha_upper

Upper case alphabet

ABCDEFGHIJKLMNOPQRSTUVWXYZ

:alphanum

Upper/lower case alphabet and numbers

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

:alphanum_lower

Lower case alphabet and numbers

abcdefghijklmnopqrstuvwxyz0123456789

:alphanum_upper

Upper case alphabet and numbers

ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

:base32

RFC 4648 base32 character set

ABCDEFGHIJKLMNOPQRSTUVWXYZ234567

:base32_hex

RFC 4648 base32 extended hex character set with lowercase letters

0123456789abcdefghijklmnopqrstuv

:base32_hex_upper

RFC 4648 base32 extended hex character set

0123456789ABCDEFGHIJKLMNOPQRSTUV

:decimal

Decimal digits

0123456789

:hex

Lowercase hexidecimal

0123456789abcdef

:hex_upper

Uppercase hexidecimal

0123456789ABCDEF

:safe32

Strings that don't look like English words and are easy to parse visually

2346789bdfghjmnpqrtBDFGHJLMNPQRT
  • remove all upper and lower case vowels (including y)
  • remove all numbers that look like letters
  • remove all letters that look like numbers
  • remove all letters that have poor distinction between upper and lower case values

:safe64

RFC 4648 file system and URL safe character set

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_

:printable_ascii

Printable ASCII characters from ?! to ?~

`!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~`

Link to this section Summary

Functions

Return pre-defined Puid.CharSet characters or :undefined

Link to this section Functions

Specs

chars(atom()) :: String.t() | :undefined

Return pre-defined Puid.CharSet characters or :undefined

Example

iex> Puid.CharSet.chars(:safe32)
"2346789bdfghjmnpqrtBDFGHJLMNPQRT"

iex> Puid.CharSet.chars(:dne)
:undefined