in reply to UTF-8 from a CGI script
A few observations regarding your utf-8 issues:
Others have already posted about binmode(), or 'use open' layers.
In addition to Perl related issues, also ensure that your fonts
for X (or Linux console), as well as your
browser (or xterm, or cat(1) ) are also able to display in utf8 charrs
using utf-8 fonts. (I use LatCyrGr-16.psf fonts for Linux console.)
- The reason the is_utf8() check failed is because of Perl's backward compatability issues. For hex values of "\x{00FF}" or less, the is_utf8() check is supposed to fail. Here are are a few examples using your variables:
binmode \*STDOUT, ':utf8'; my $u_temp = "Temperature:350\x{00B0}F html:°"; my $smiley = "Smiley:\x{263a}"; my $price_label = "Price:\x{20AC}9.99"; print 'is degree' if utf8::is_utf8( $u_temp ); print 'is smiley' if utf8::is_utf8( $smiley ); print 'is price label' if utf8::is_utf8( $price_label );
In Section
Seekers of Perl Wisdom