zemplen has asked for the wisdom of the Perl Monks concerning the following question:
#perl -w require 5.8.0; use strict; use utf8; use Encode; ${^WIDE_SYSTEM_CALLS} = 1; #no warnings 'utf8'; open STDOUT, "> STDOUT"; binmode(STDOUT, ":utf8"); open STDERR, "> STDERR"; binmode(STDERR, ":utf8"); my @a_lc_grave = ('à', "\x{00E0}", 'a'); my @a_lc_diaeresis = ('ä', "\x{00E4}", 'a'); my @acy = ('а', "\x{0430}", ''); my @dcy = ('д', "\x{0434}", ''); my $text = ''; $text = ${a_lc_grave[1] . ${a_lc_diaeresis[1]}}; Encode::encode_utf8($text); &test("success"); $text = ${a_lc_diaeresis[1]} . ${a_lc_grave[1]}; Encode::encode_utf8($text); &test("fail"); $text = ${a_lc_grave[1]} . ${a_lc_grave[1]}; Encode::encode_utf8($text); &test("success"); $text = ${a_lc_diaeresis[1]} . ${a_lc_diaeresis[1]}; Encode::encode_utf8($text); &test("success"); sub test () { print "-"x20, "\n"; print $_[0], "\n"; print "Before = ", unpack ("U*", ${text}), "\n\n"; $text=~s/${a_lc_diaeresis[1]}/${dcy[1]}/g; $text=~s/${a_lc_grave[1]}/${acy[1]}/g; print "After = ", unpack ("U*", ${text}), "\n\n"; print $text, "\n\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: utf8 encoding bug?
by hv (Prior) on Feb 25, 2003 at 16:21 UTC | |
|
Re: utf8 encoding bug?
by zemplen (Novice) on Feb 25, 2003 at 17:50 UTC | |
by hv (Prior) on Feb 25, 2003 at 18:49 UTC |