#!/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; }
Call as: http://baz.perlmonk.org/euro.cgi?cs=%E2%82%AC

In reply to Re^2: Passing unicode via html forms by Baz
in thread Passing unicode via html forms by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.