in reply to doulbe/triple/multi encoded utf8
sub multidecode_utf8 { my $s = shift; 1 while $s =~ tr/\x80-\xFF// && utf8::decode($s); return $s; }
Tested with:
use strict; use warnings; use Test::More tests => 12; for my $orig ( "abc", "\xC9ric", "\x{2660}\x{2661}\x{2662}\x{2663}", ) { my $str = $orig; for (0..3) { is multidecode_utf8($str), $orig; utf8::encode($str); } }
|
|---|