in reply to Re: tr{}{} doesn't wanna work.. what am I doing wrong?
in thread tr{}{} doesn't wanna work.. what am I doing wrong?
tr and Unicode don't mix well
In what way? Seems to work fine for me. Could you provide an example that fails? (just curious)
use Devel::Peek; my $test = "\x{2345}\x{3456}"; Dump $test; $test =~ tr/\x{2345}\x{3456}/XY/; Dump $test; __END__ SV = PV(0x768bc8) at 0x7907d8 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) PV = 0x782630 "\342\215\205\343\221\226"\0 [UTF8 "\x{2345}\x{3456}"] CUR = 6 LEN = 8 SV = PV(0x768bc8) at 0x7907d8 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) PV = 0x782630 "XY"\0 [UTF8 "XY"] CUR = 2 LEN = 8
(I'm only using \x{...} here because PM code sections don't support Unicode — it works the same way with a UTF-8 encoded source file when using "use utf8;")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: tr{}{} doesn't wanna work.. what am I doing wrong?
by moritz (Cardinal) on Feb 24, 2012 at 14:43 UTC | |
by Eliya (Vicar) on Feb 24, 2012 at 15:12 UTC | |
by tchrist (Pilgrim) on Feb 25, 2012 at 01:18 UTC |