Ok, ok. Although from my perspective, there's little sense in getting (2), it might make sense in situations beyond me.
Apart from that, my use case (where the problem occurred) requires "round trip integrity", meaning: Given a string, I can...
- -> encode it as JSON
- -> write it to db
- -> read it back
- -> decode from JSON
... and have the same Perl structure as before, or differently said, a structure behaving like before (this tiny differentiation to leave room for: ok, I didn't check if the utf-8 flag was set...)
With my "round trip", relying on JSON::to_json(), the data structure blew from_json() on the "decode from JSON" step.
(Original test script updated). Devel Peek output:
OK
SV = PV(0x4178620) at 0x4042060
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x4170620 "Hello \342\200\223 World"\0 UTF8 "Hello \x{2013} World"
CUR = 15
LEN = 24
SV = PV(0x41785f0) at 0x4049b18
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x4170590 "\"Hello \342\200\223 World\""\0 [UTF8 ""Hello \x{2013} World""]
CUR = 19
LEN = 40
CRASH
SV = PV(0x4178580) at 0x40a2548
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x4170600 "Hello \342\200\223 World"\0 UTF8 "Hello \x{2013} World"
CUR = 15
LEN = 24
SV = PV(0x41783d0) at 0x40a28d8
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x4176460 "\"Hello \342\200\223 World\""\0 [UTF8 ""Hello \x{2013} World""]
CUR = 19
LEN = 40
Huh? I don't see it... but wait! \x{2013} doesn't look like utf-8.. Should be \xE2\x80\x93, no?
This output was nonsense, as utf8::decode() altered the strings to be the same at the Dump() stage (as tye and Anon Monk pointed out) (test script updated) (
new output here)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.