[interchange] Patch [area] to accept decoded strings.
Stefan Hornburg <[email protected]>
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit ce493f1cbfe196d8b6b3a636e95ea6e351060b89 Author: Marco Pessotto <[email protected]> Date: Mon Feb 17 16:02:30 2014 +0100 Patch [area] to accept decoded strings. is_utf8 is badly name. First, it's an internal function, but it's used all over the place in IC. From the doc: is_utf8(STRING [, CHECK]) [INTERNAL] Tests whether the UTF8 flag is turned on in the STRING. If CHECK is true, also checks the data in STRING for being well-formed UTF-8. Returns true if successful, false otherwise. So, basically, is_utf8 returns true if the string is decoded, not when is encoded in utf8. use strict; use warnings; use utf8; ok(is_utf8("à")); diag "When we encode, the string is not \"utf8\" any more"; ok(!is_utf8(encode(utf8 => 'à'))); lib/Vend/Util.pm | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) --- diff --git a/lib/Vend/Util.pm b/lib/Vend/Util.pm index 2152bad..97d6c69 100644 --- a/lib/Vend/Util.pm +++ b/lib/Vend/Util.pm @@ -189,6 +189,12 @@ sub escape_chars_url { my($c, $r); $r = ''; + if ($::Variable->{MV_UTF8} || $Global::Variable->{MV_UTF8}) { + # check if it's decoded + if (is_utf8($in)) { + $in = encode_utf8($in); + } + } foreach $c (split(m{}, $in)) { $r .= $ESCAPE_CHARS::translate_url[ord($c)]; } _______________________________________________ interchange-cvs mailing list [email protected] http://www.icdevgroup.org/mailman/listinfo/interchange-cvs