Help for this page

Select Code to Download


  1. or download this
    @codepoints = map ord($_), split //, $s1;
    $s2 = join '', map chr($_), @codepoints;
    ok($s1 eq $s2);
    ok(length($s1) == length($s2);
    
  2. or download this
    $s1 = "abc\x80";
    $s2 = $s1;        # currently SVf_UTF8 not set; string uses 4 bytes of
    + storage
    ...
    chop($s2);        # currently perl doesn't downgrade; the 0x80 codepoi
    +nt still stored as 2 bytes
    ok($s1 eq $s2);
    ok(length($s1) == length($s2));
    
  3. or download this
    utf8::downgrade($s2); # the the 0x80 codepoint now stored as 1 byte
    ok(length($s1) == $length($s2));
    ok($s1 eq $s2);