in reply to a new example
G'day Raymond,
Here's a few examples that may clarify the differences between handling UTF-8 in your output and in your source code. Here's how those characters should render: Ä = Ä and Δ = Δ. I've used <pre>...</pre> tags so that the characters (e.g. Δ), and not the entities (e.g. Δ), are displayed.
Baseline code generating "Wide character" warning:
$ perl -Mstrict -Mwarnings -E '
say "\xC4 and \x{0394} look different";
'
Wide character in say at -e line 2.
Ä and Δ look different
Using binmode function to specify UTF-8 output:
$ perl -Mstrict -Mwarnings -E '
binmode STDOUT => ":utf8";
say "\xC4 and \x{0394} look different";
'
Ä and Δ look different
Using the open pragma to specify UTF-8 output:
$ perl -Mstrict -Mwarnings -E '
use open qw{:std :utf8};
say "\xC4 and \x{0394} look different";
'
Ä and Δ look different
Attempting to use UTF-8 in the source code without letting Perl know:
$ perl -Mstrict -Mwarnings -E '
binmode STDOUT => ":utf8";
say "\xC4 and \x{0394} look different";
say "Ä and \x{c4} look different";
say "Δ and \x{0394} look different";
'
Ä and Δ look different
à and Ä look different
Î and Δ look different
Using the utf8 pragma to tell Perl there's UTF-8 in the source code:
$ perl -Mstrict -Mwarnings -E '
use utf8;
binmode STDOUT => ":utf8";
say "\xC4 and \x{0394} look different";
say "Ä and \x{c4} look the same";
say "Δ and \x{0394} look the same";
'
Ä and Δ look different
Ä and Ä look the same
Δ and Δ look the same
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
5.pl i have another new example
by Raymond (Novice) on Jul 29, 2013 at 23:09 UTC | |
by ww (Archbishop) on Jul 30, 2013 at 00:41 UTC | |
by kcott (Archbishop) on Jul 30, 2013 at 05:34 UTC | |
by Raymond (Novice) on Jul 30, 2013 at 19:08 UTC |