in reply to pack mangles utf output
$ use Devel::Peek
$ Dump pack 'A20', "FREIGHT – INTRASTATE"
SV = PV(0x4a5bce0) at 0x4a29660
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK,UTF8)
PV = 0x4644800 "FREIGHT \342\200\223 INTRASTATE"\0 [UTF8 "FREIGHT \x{2013} INTRASTATE"]
CUR = 22
LEN = 40
[]
$ open my $fh, '>:encoding(UTF-8)', '/tmp/foobar'
1
$ $fh->print(pack 'A20', "FREIGHT – INTRASTATE")
1
/tmp$ hex /tmp/foobar
0000 46 52 45 49 47 48 54 20 e2 80 93 20 49 4e 54 52 FREIGHT – INTR
0010 41 53 54 41 54 45 ASTATE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pack mangles utf output
by roho (Bishop) on Aug 28, 2013 at 15:29 UTC | |
by vsespb (Chaplain) on Aug 28, 2013 at 15:50 UTC |