Re: Compress::Zlib, pack "C" and utf-8 [PATCH]
[p5sagit/p5-mst-13.2.git] / lib / CGI / Util.pm
index 9cef416..0cb6e51 100644 (file)
@@ -200,8 +200,8 @@ sub escape {
   shift() if @_ > 1 and ( ref($_[0]) || (defined $_[1] && $_[0] eq $CGI::DefaultClass));
   my $toencode = shift;
   return undef unless defined($toencode);
-  # force bytes while preserving backward compatibility -- dankogai
-  $toencode = pack("C*", unpack("C*", $toencode));
+  # we enforce UTF-8 encoding for URLs for no good reason except UTF-8 being the future
+  utf8::encode $toencode;
     if ($EBCDIC) {
       $toencode=~s/([^a-zA-Z0-9_.~-])/uc sprintf("%%%02x",$E2A[ord($1)])/eg;
     } else {