I faced out with some problems, when tried to read unicode strings from the file. It was smth like:
open FH, '<:utf8', 'input.txt'
or die $!
my $str = <FH>;
close FH;
This file contains one letter. In the hex editor it looks like:
C3 A0
And in the text editor it is "à". I think it is italian.
When I tried to
print $str;
I expected "Wide character in print" and this letter after, but all that I get is question mark inside black box "�".
Here are quick examples:
echo -e "\xC3\xA0" | perl -pne 'BEGIN{binmode STDIN, ":utf8"}'
echo -e "\xD0\xBC" | perl -pne 'BEGIN{binmode STDIN, ":utf8"}'
output of the first example is as described above, but second works as expected (with "Wide character in print" and expected letter - "м" - from the cyrillic alphabet)
Please, tell me where is a problem.
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.