|Welcome to the Monastery|
Re: special characters in parsed json rendering badly in browserby slugger415 (Monk)
|on Sep 09, 2018 at 13:55 UTC||Need Help??|
Thank you all for your suggestions but I don't feel I'm any closer with this problem, partly my own fault for not being clear what I want. (Which i'm figuring out as I puzzle it out.) I'd like the text/data to be portable to other applications that can read HTML.
I did figure out (thanks poj) that I can set the encoding in the HTML page to have it display correctly in the browser. But if that text gets posted to another page or app I don't necessarily have control over its page encoding.
SO what I really want is to HTML encode those characters. But when I try HTML::Encode: for, say, the smart apostrophe:
that one character gets converted to three HTML entities:
which displays a lot of garbage in the browser.
So I'm lost as to what's going on or how to resolve it. Perl is rendering the JSON string as a smart quote but HTML::Encode is improperly encoding it.
So far my best solution seems to be:
but of course that only handles characters I'm aware of.
Thoughts? Thanks for your patience.