Trying to debug an encoding problem? The following will try to figure out what encoding was used and what encoding should have been used.

use 5.008; use strict; use warnings; use Encode qw( encode decode ); use charnames qw( :full ); my $expected = "\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}"; my $got = "\N{LATIN CAPITAL LETTER A WITH TILDE}" . "\N{LATIN CAPITAL LETTER Z WITH CARON}"; my @encs = ( 'US-ASCII', ( map "UTF-$_", qw( 7 8 16be 16le 32be 32le ) ), ( map "UCS-$_", qw( 2be 2le 4be 4le ) ), ( map "iso-8859-$_", 1..11, 13..16 ), ( map "Windows-$_", 437, 737, 775, 850, 852, 855, # OEM pages 857, 858, 860, 861, 862, 863, 865, 866, 869, 874, 932, 936, 949, 950, # ANSI pages 1250..1258, ), ); for my $enc_for_enc (@encs) { my $encoded = encode($enc_for_enc, $expected); for my $enc_for_dec (@encs) { my $decoded = decode($enc_for_dec, $encoded); next if $decoded ne $got; print("$enc_for_enc as $enc_for_dec:\n"); for ($decoded =~ /./sg) { my $code = ord; my $name = charnames::viacode($code); printf("(U+%04X) %s\n", $code, $name); } print("\n"); } }
UTF-8 as Windows-1252: (U+00C3) LATIN CAPITAL LETTER A WITH TILDE (U+017D) LATIN CAPITAL LETTER Z WITH CARON

Known bugs and limitations:


In reply to Find encoding that should have been used by ikegami

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.