- or download this
use Encode qw( decode );
...
$s = do { use utf8; "高" };
print(length($s), "\n"); # 1
- or download this
use Encode qw( encode );
...
$s2 = encode('utf8', $s);
print(length($s2), "\n"); # 3
- or download this
use strict;
use warnings;
...
binmode(STDOUT, ':utf8');
print("$chars_src\n");
print("$chars_dst\n");
- or download this
...
...
print("$bytes_src\n");
print("$bytes_dst\n");
- or download this
...
...
print("$chars_src\n");
binmode(STDOUT, ':bytes');
print("$bytes_dst\n");