Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:47:03+00:00 2026-06-15T02:47:03+00:00

I am running a SQL query on a WordPress blog to a get json

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:47:04+00:00Added an answer on June 15, 2026 at 2:47 am

    I have had the similar problem like you in another programming language.

    This is not utf8 encode but url encode.

    Try to use:

    urlencode(string)
    

    and

    urldecode(string)
    

    In the 2 cases (with decoding all the %char change 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

        while($r = mysql_fetch_assoc($sth)) {
        if $r is a url
        $rows = decode($r);
        else
        $rows[] = $r;   
        }
    

    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:

    print strip_tags(json_encode($rows));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in a very, very tight situation here. I have an SQL query running
When running a SQL query with output to text we typically get back output
I'm running SQL query for MySQL server with ... where name in (term1,term2,term3) I
I am running an SQL query which self-joins the same table 24 times in
the current SQL query works fine locally on MAMP 1.8.4 running MySQL 5.1.37. SELECT
I am running a sql in PHP query that is dieing with the mysql_error()
I recently discovered that a sql query that was running fine earlier is now
I am running following query in SQL*Plus CREATE TABLE tbl_audit_trail ( id NUMBER(11) NOT
I am running a SQL query that returns a table of results. I want
Presently troubleshooting a problem where running this SQL query: UPDATE tblBenchmarkData SET OriginalValue =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.