Call as: http://baz.perlmonk.org/euro.cgi?cs=%E2%82%AC#!/usr/bin/perl -w use CGI; use CGI::Carp "fatalsToBrowser"; use HTML::Template; use Encode; my $cgi = new CGI; my $sym = $cgi->param('cs') || ''; my $euro = "\x{20AC}"; my $charset = "utf-8"; Encode::_utf8_on($sym); print $cgi->header(-charset => $charset), $cgi->start_html ( -encoding => $charset, -head => $cgi->meta({-http_equiv => "Content-Type", -content => "text/html; charset=".$charset}), -title => "Euro", ), $sym, $cgi->br, UnicodeString(($sym)), $cgi->br, UnicodeString($euro),$cgi->br; if($euro eq $sym) { print "match"; } print $cgi->end_html; sub UnicodeString{ my $str; join("", map { $str .= sprintf("0x%04X ", $_) # \x{...} } unpack("U*", $_[0])); # unpack Unicode characters return $str; }
In reply to Re^2: Passing unicode via html forms
by Baz
in thread Passing unicode via html forms
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |