From fbd9cb9588cd10ee97ee125e035a652105de57e5 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 10 Sep 2012 09:36:27 +0200 Subject: [PATCH] Added `HTML_ENCODER.general_encoded_string (s: READABLE_STRING_GENERAL): STRING_8' (note: probably we should do similar change for all the encoders) --- library/text/encoder/src/html_encoder.e | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/library/text/encoder/src/html_encoder.e b/library/text/encoder/src/html_encoder.e index 796fe95b..b066c00c 100644 --- a/library/text/encoder/src/html_encoder.e +++ b/library/text/encoder/src/html_encoder.e @@ -36,19 +36,25 @@ feature -- Encoder encoded_string (s: READABLE_STRING_32): STRING_8 -- HTML-encoded value of `s'. + do + Result := general_encoded_string (s) + end + + general_encoded_string (s: READABLE_STRING_GENERAL): STRING_8 + -- The HTML-encoded equivalent of the given string + -- HTML-encoded value of `s'. local i, n: INTEGER - uc: CHARACTER_32 - l_code: INTEGER + l_code: NATURAL_32 c: CHARACTER_8 do has_error := False create Result.make (s.count + s.count // 10) n := s.count from i := 1 until i > n loop - uc := s.item (i) - if uc.is_character_8 then - c := uc.to_character_8 + l_code := s.code (i) + if l_code.is_valid_character_8_code then + c := l_code.to_character_8 inspect c when '%T', '%N', '%R' then @@ -59,7 +65,6 @@ feature -- Encoder when '<' then Result.append_string ("<") when '>' then Result.append_string (">") else - l_code := c.code if l_code <= 31 or -- Hexa 1F l_code = 127 -- Hexa 7F @@ -77,7 +82,7 @@ feature -- Encoder end else Result.append ("&#") - Result.append (uc.code.out) + Result.append (l_code.out) Result.extend (';') end i := i + 1