Created
January 13, 2018 09:35
-
-
Save drozdzynski/bc6ddc39a9e7bb7ea6ff456788fad9cc to your computer and use it in GitHub Desktop.
Elixir CodePoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule CodePoint do | |
def encode(character) when is_binary(character) do | |
[code_point] = String.to_charlist(character) | |
Integer.to_string(code_point, 16) | |
end | |
def decode(code_point) when is_binary(code_point) do | |
[String.to_integer(code_point, 16)] |> to_string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment