use Encode qw(decode);
sub decode_it {
my $s = shift;
eval {
$s = decode('UTF-8', $s, 1);
1;
} or do {
$s = decode('latin1', $s, 1);
};
return $s;
}
use Devel::Peek qw(Dump);
Dump decode_it($_) for "\xE2\x84\xA2", "\xE7\xE1";
__END__
SV = PV(0x100820708) at 0x10081c248
REFCNT = 1
FLAGS = (TEMP,POK,pPOK,UTF8)
PV = 0x100202140 "\342\204\242"\0 [UTF8 "\x{2122}"]
CUR = 3
LEN = 8
SV = PV(0x100820748) at 0x100860ee0
REFCNT = 1
FLAGS = (TEMP,POK,pPOK,UTF8)
PV = 0x10025dec0 "\303\247\303\241"\0 [UTF8 "\x{e7}\x{e1}"]
CUR = 4
LEN = 8
Once decoded by
decode_it, your character strings are ready to be UTF-8 encoded right before you put it out onto your web page.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.