Skip to content

Instantly share code, notes, and snippets.

@talentdeficit
Created December 1, 2014 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talentdeficit/849183f95cabdae51f93 to your computer and use it in GitHub Desktop.
Save talentdeficit/849183f95cabdae51f93 to your computer and use it in GitHub Desktop.
defp string_escape(<<?u, a1, b1, c1, d1, "\\u", a2, b2, c2, d2>> <> rest, acc)
when a1 in 'dD' and a2 in 'dD'
and (b1 in '89abAB')
and (b2 in ?c..?f or b2 in ?C..?F) \
do
hi = List.to_integer([a1, b1, c1, d1], 16)
lo = List.to_integer([a2, b2, c2, d2], 16)
codepoint = 0x10000 + ((hi &&& 0x03FF) <<< 10) + (lo &&& 0x03FF)
string_continue(rest, [acc, <<codepoint :: utf8>>])
end
---
== Compilation error on file lib/poison.ex ==
** (CompileError) lib/poison.ex:37: function '&&&'/2 undefined
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment