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

  • SEARCH
  • Home
  • 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 6658193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:51:48+00:00 2026-05-26T01:51:48+00:00

I store a json string that contains some (chinese ?) characters in a mysql

  • 0

I store a json string that contains some (chinese ?) characters in a mysql database.
Example of what’s in the database:

normal.text.\u8bf1\u60d1.rest.of.text

On my PHP page I just do a json_decode of what I receive from mysql, but it doesn’t display right, it shows things like “½±è§�”

I’ve tried to execute the “SET NAMES ‘utf8′” query at the beginning of my file, didn’t change anything.
I already have the following header on my webpage:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

And of course all my php files are encoded in UTF-8.

Do you have any idea how to display these “\uXXXX” characters nicely?

  • 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-05-26T01:51:48+00:00Added an answer on May 26, 2026 at 1:51 am

    Unicode is not UTF-8!

    $ echo -en '\x8b\xf1\x60\xd1\x00\n' | iconv -f unicodebig -t utf-8
    诱惑
    

    This is a strange “encoding” you have. I guess each character of the normal text is “one byte” long (US-ASCII)? Then you have to extract the \u…. sequences, convert the sequence in a “two byte” character and convert that character with iconv("unicodebig", "utf-8", $character) to an UTF-8 character (see iconv in the PHP-documentation). This worked on my side:

    $in = "normal.text.\u8bf1\u60d1.rest.of.text";
    
    function ewchar_to_utf8($matches) {
        $ewchar = $matches[1];
        $binwchar = hexdec($ewchar);
        $wchar = chr(($binwchar >> 8) & 0xFF) . chr(($binwchar) & 0xFF);
        return iconv("unicodebig", "utf-8", $wchar);
    }
    
    function special_unicode_to_utf8($str) {
        return preg_replace_callback("/\\\u([[:xdigit:]]{4})/i", "ewchar_to_utf8", $str);
    }
    
    echo special_unicode_to_utf8($in);
    

    Otherwise we need more Information on how your string in the database is encoded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I store some time values in sqlite in %H:%M string format (for example 15:43),
I have a database (MS SQL) with a column that contains a query string.
I'm getting this json string info from the server : {members:[[sd2840d,Johny],[jkld341,Marry]]} So I store
I am trying to store a json encoded array into a MySQL field. The
I store various user details in my MySQL database. Originally it was set up
I have a web service that returns a decimal value into my json string
I have a JSON object being returned to my app that contains a date
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I have a table in which I need to store some serialized json strings
Functionality in an iPhone app that searches twitter for some text. The code is

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.