Fix  . Display too large numeric entities as they are.

This commit is contained in:
Mikko Ahlroth 2013-08-21 10:45:15 +03:00
parent 2c4c559544
commit 35dbc8e731

View file

@ -49,8 +49,8 @@ defmodule ExCoder do
{ "|", "|" },
{ "}", "}" },
{ "}", "}" },
{ " ", " " },
{ " ", " " },
{ " ", " " },
{ " ", " " },
{ "¡", "¡" },
{ "¢", "¢" },
{ "£", "£" },
@ -2056,22 +2056,22 @@ defmodule ExCoder do
def decode(str), do: String.first(str) <> decode String.slice str, 1, String.length str
def decode(numeric, :numericmode) when is_number numeric do
def decode(numeric, :numericmode, original) when is_number numeric do
if numeric <= @max_codepoint do
<< numeric :: utf8 >>
else
""
"&#" <> original <> ";"
end
end
def decode(<< "x", rest :: binary >>, :numericmode) do
[numeric | rest] = strip_numeric rest
decode(binary_to_integer(numeric, 16), :numericmode) <> decode(Enum.join rest, ";")
decode(binary_to_integer(numeric, 16), :numericmode, "x" <> numeric) <> decode(Enum.join rest, ";")
end
def decode(str, :numericmode) do
[numeric | rest] = strip_numeric str
decode(binary_to_integer(numeric), :numericmode) <> decode(Enum.join rest, ";")
decode(binary_to_integer(numeric), :numericmode, numeric) <> decode(Enum.join rest, ";")
end