Help for this page

Select Code to Download


  1. or download this
    my $s="\x{5fcd}\x{65e0}\x{53ef}\x{5fcd}";
    use Encode;
    print length encode("utf8", $s), "\n"; # 12
    
  2. or download this
    print do {use bytes; length($s)}, "\n"; # 12 (see perldoc -f length)
    
    ...
    
    utf8::encode($s); # resets the utf8 flag
    print length($s), "\n"; # 12