(Don't worry know how to open a file:) I can't guanantee the encoding of the external file...

As moritz points out, if you don't know what encoding is being used in the file, then you don't really know how to open the file.

If you're actually dealing with a bunch of different files that may be in different encodings, then Encode::Guess is probably the only way to go. But if the input is known to be consistent, maybe you just need to figure out once what the encoding is, and write your script to handle that encoding.

There really aren't very many different choices when it comes to French; "é" in a single-byte encoding might be either 0x82 (older PC code pages with 3-digit numbers, eg. CP437, CP720, etc), 0x8E (older Mac code pages) or 0xE9 (various iso-8859-n and Windows CP125n).

In multi-byte form, it's most likely unicode (0xC3 0xa9 in utf8, or 0x00E9 in utf-16 -- but this latter could be either big- or little-endian).

Just use some sort of hex dump tool on your file to see what it is, and use the proper encoding as an IO layer when opening the file:

open( my $fh, "<:cp1252", "file.name" ) or die $!; # assuming it's cp +1252

In reply to Re: Reguar expressions and french characters by graff
in thread Reguar expressions and french characters by wardazo

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.