1# 2# $Id: cow.t,v 1.2 2016/08/04 03:15:58 dankogai Exp $ 3# 4use strict; 5use Encode (); 6use Test::More tests => 4; 7 8 9my %a = ( "L\x{c3}\x{a9}on" => "acme" ); 10my ($k) = ( keys %a ); 11Encode::_utf8_on($k); 12my %h = ( $k => "acme" ); 13is $h{"L\x{e9}on"} => 'acme'; 14($k) = ( keys %h ); 15Encode::_utf8_off($k); 16%a = ( $k => "acme" ); 17is $h{"L\x{e9}on"} => 'acme'; 18# use Devel::Peek; 19# Dump(\%h); 20 21{ # invalid input to encode/decode/from_to should not affect COW-shared scalars 22 my $x = Encode::decode('UTF-8', "\303\244" x 4); 23 my $orig = "$x"; # non-COW copy 24 is($x, $orig, "copy of original string matches"); 25 { my $y = $x; Encode::from_to($y, "UTF-8", "iso-8859-1"); } 26 is($x, $orig, "original scalar unmodified after from_to() call"); 27} 28