The first reply gives the correct answer about how to "change the codepage when perl saves the file", but the experiment proposed by the Anonymous Monk above is important.

Problems with character encodings for non-ASCII text are difficult to describe clearly. If you know what specific encoding(s) you are dealing with (or would like to use), you need to be clear about that -- name them. If you can't figure out the explicit name(s), then it is certainly helpful to say what language you are dealing with (thanks for doing that).

When characters are simply not coherent, it helps to have an explicit numeric rendering of the byte sequence (e.g. using hex digits for each byte value). The pack function is handy for this, though it can be a little tough to figure out sometimes... Another way is:

my $hexstring = join " ", map { sprintf("0x%04x",ord()) } split //, $f +oobar_string;
(Update: changed incorrect use of "chr()" to correct use of "ord()".)

That will print every "character" of a string as a four-digit hex number (with leading zeros, e.g. 0x0041 for "A"). If the original string is being treated by perl as single-byte "characters", the hex numbers will all start with "0x00"; if the string is flagged as containing utf8 characters, the hex numbers will be the 16-bit values representing unicode "codepoints". Using a technique like this to know what is in your data (whether file contents or file names) is usually very helpful.


In reply to Re: changing codepage while saving to a text file by graff
in thread changing codepage while saving to a text file by atnonis

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.