I am running a SQL query on a WordPress blog to a get json feed of posts. Here is my code: http://pastebin.com/jvaM9ySr
It works fine but some of the post url’s are coming through with what I think are UTF-8 special characters like
ranking-of-the-country%e2%80%99s-101-best-desserts
where I guess a blog editor pasted in a fancy apostrophe.
other examples have %e2%84%a2 in the middle of the url for the trademark symbol and even %cf%83 for the greek sigma letter.
I’d like to convert these to show what the actual special character is in the json feed.
I am using this to match the urls in the Google Analytics API and the corresponding Analytics urls contain the special character itself and not code like:
ranking-of-the-country’s-101-best-desserts
so these few cases aren’t matching because of this special character issue.
I’ve tried to use utf8_encode and utf8_decode in various places in the code that is in the pastebin with no luck.
Any one have any ideas? Thanks!
I have had the similar problem like you in another programming language.
This is not
utf8 encodebuturl encode.Try to use:
and
In the 2 cases (with decoding all the
%charchange with the correct utf char).Here you can find more information and examples: http://php.net/manual/en/function.urlencode.php
UPDATE:
for your code: I haven’t tested, but you must or decoding the url when you store the response value here
OR
differentiate the printing at the end of your code (something like the code before): doing for each variable in the array the appropriate printing (and when you “catch” the “url” you do the decoding), here: