From 35dbc8e731ebaa06a61b1ac1d490b3842040adb4 Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Wed, 21 Aug 2013 10:45:15 +0300 Subject: [PATCH] Fix  . Display too large numeric entities as they are. --- lib/excoder.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/excoder.ex b/lib/excoder.ex index 6d70e90..e7d1c33 100644 --- a/lib/excoder.ex +++ b/lib/excoder.ex @@ -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