Skip to content

l1h3r/gsm

Repository files navigation

GSM

GSM-7 encoding for Elixir

Build Status Coverage Status Hex.pm Hex.pm

GSM 03.38

Installation

def deps do
  [
    {:gsm, "~> 0.1.0"}
  ]
end

Usage

GSM-7 conversion

iex> GSM.to_gsm("foo")
"foo"

iex> GSM.to_gsm("bar :]")
"bar :\e>"

iex> GSM.to_gsm("баz")
** (GSM.BadCharacter) Unsupported GSM-7 character: "б"

GSM-7 validation

# Test if valid GSM string
iex> GSM.valid?("foo :]")
true

iex> GSM.valid?("баz")
false

# Test if 2-byte GSM character
iex> GSM.double?("|")
true

iex> GSM.double?(":")
false

UTF-8 conversion

iex> GSM.to_utf8("foo :\e>")
"foo :]"

iex> GSM.to_utf8("∫")
** (GSM.BadCharacter) Unsupported GSM-7 character: "∫"