in reply to UTF8 hash key downgraded when assigned
Seems to work fine for me if I rewrite your script as:Malformed UTF-8 character: \xe9\x27\x20 (unexpected non-continuation b +yte 0x27,immediately after start byte 0xe9; need 3 bytes, got 1) at t +ry.pl line 11. Malformed UTF-8 character (fatal) at try.pl line 11.
UPDATE: When I initially posted this rewritten version, my utf8::upgrade($s); was done inside the no utf8{} block - which is rather counter-intuitive, to say the least.#!/usr/bin/perl use strict; use warnings; use utf8; use Devel::Peek; use Data::Dumper; $Data::Dumper::Useqq = 1; my $s; { no utf8; $s = 'clé'; } utf8::upgrade($s); my %hash = ( $s => 0, ); my $key = (keys %hash)[0]; Dump($key); print Dumper($key); $hash{$s} = 1; $key = (keys %hash)[0]; Dump($key); print Dumper($key); utf8::upgrade($key); # does nothing Dump($key); print Dumper($key);
SV = PV(0x84c2a8) at 0x373100 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x247ede8 "cl\303\251"\0 [UTF8 "cl\x{e9}"] CUR = 4 LEN = 5 $VAR1 = "cl\x{e9}"; SV = PV(0x84c2a8) at 0x373100 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x247f4d8 "cl\303\251"\0 [UTF8 "cl\x{e9}"] CUR = 4 LEN = 5 $VAR1 = "cl\x{e9}"; SV = PV(0x84c2a8) at 0x373100 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x247f4d8 "cl\303\251"\0 [UTF8 "cl\x{e9}"] CUR = 4 LEN = 5 $VAR1 = "cl\x{e9}";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF8 hash key downgraded when assigned
by choroba (Cardinal) on Dec 01, 2018 at 01:07 UTC | |
by syphilis (Archbishop) on Dec 01, 2018 at 01:44 UTC | |
by ikegami (Patriarch) on Dec 01, 2018 at 04:01 UTC | |
by syphilis (Archbishop) on Dec 01, 2018 at 05:18 UTC |