Skip to content

Instantly share code, notes, and snippets.

@padde
Created June 5, 2015 17:10
Show Gist options
  • Save padde/08b257f7aba523318156 to your computer and use it in GitHub Desktop.
Save padde/08b257f7aba523318156 to your computer and use it in GitHub Desktop.
Elixir Unicode Pattern Matching
iex> <<first, rest::binary>> = "☺ how dare you, unicode!"
"☺ how dare you, unicode!"
iex> <<first>>
<<226>>
iex> rest
<<152, 186, 32, 104, 111, 119, 32, 100, 97, 114, 101, 32, 121, 111, 117, 44, 32, 117, 110, 105, 99, 111, 100, 101, 33>>
iex> <<first::utf8, rest::binary>> = "☺ how dare you, unicode!"
"☺ how dare you, unicode!"
iex> <<first::utf8>>
"☺"
iex> rest
" how dare you, unicode!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment