I use Activeperl version 5.8.8.817 on windows xp.
I try create a new text file and add some content but when I open it
in notepad, it says its a ansi encoded file. Why?
open my $fh, '>:encoding(UTF-8)', "testfile.txt";
print $fh "Welcome to Muppet Show\n";
close $fh;
What do I do wrong?
Your sample text has the identical byte sequence in ASCII, Windows-1252 (aka
ANSI), UTF-8, ISO-Latin1, ISO-Latin15, and probably a dozen other encodings.
Therefore your sample is useless for testing for the correct encoding.
Notepad relies on the byte order mark (BOM) do identify Unicode files,
including UTF-8 where the BOM of course is meaningless and not used except
by Notepad itself. In not so many words: Notepad has no clue what it is
talking about. But for your sample text nor would any other tool.
Step 1: use some sample text that contains characters, that have different
code points in each encoding.
Step 2: don't use Notepad. Write to a (trivial) HTML file and then use a web
browser to view that file. There you can change the encoding and determine,
if those characters are displayed correctly for the desired encoding.
In over 8 years as software localization engineer and international program
manager this has proven to be the only practical and reliable way to
identify the actual encoding of a file.
jue