Help for this page

Select Code to Download


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