Fix . Display too large numeric entities as they are.
This commit is contained in:
parent
2c4c559544
commit
35dbc8e731
1 changed files with 6 additions and 6 deletions
|
@ -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(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
|
if numeric <= @max_codepoint do
|
||||||
<< numeric :: utf8 >>
|
<< numeric :: utf8 >>
|
||||||
else
|
else
|
||||||
""
|
"&#" <> original <> ";"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode(<< "x", rest :: binary >>, :numericmode) do
|
def decode(<< "x", rest :: binary >>, :numericmode) do
|
||||||
[numeric | rest] = strip_numeric rest
|
[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
|
end
|
||||||
|
|
||||||
def decode(str, :numericmode) do
|
def decode(str, :numericmode) do
|
||||||
[numeric | rest] = strip_numeric str
|
[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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue