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 246403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:10:11+00:00 2026-05-11T21:10:11+00:00

I use JSON to encode an array, and I get a string like this:

  • 0

I use JSON to encode an array, and I get a string like this:

{"name":"\u00fe\u00fd\u00f0\u00f6\u00e7"}

Now I need to convert this to ISO-8859-9. I tried the following but it fails:

header('Content-type: application/json; charset=ISO-8859-9');
$json = json_encode($response);
$json = utf8_decode($json);
$json = mb_convert_encoding($json, "ISO-8859-9", "auto");
echo $json;

It doesnt seem to work. What am I missing?

Thank you for your time.

  • 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-11T21:10:11+00:00Added an answer on May 11, 2026 at 9:10 pm

    You can do:

    $json = json_encode($response);
    header('Content-type: application/json; charset=ISO-8859-9');
    echo mb_convert_encoding($json, "ISO-8859-9", "UTF-8");
    

    Assuming that strings in $response is in utf-8. But I would strongly suggest that you just use utf-8 all the way through.

    Edit: Sorry, just realised that won’t work, since json_encode escapes unicode points as javascript escape codes. You’ll have to convert these to utf-8 sequences first. I don’t think there are any built-in functionality for that, but you can use a slightly modified variation of this library to get there. Try the following:

    function unicode_hex_to_utf8($hexcode) {
      $arr = array(hexdec(substr($hexcode[1], 0, 2)), hexdec(substr($hexcode[1], 2, 2)));
      $dest = '';
      foreach ($arr as $src) {
        if ($src < 0) {
          return false;
        } elseif ( $src <= 0x007f) {
          $dest .= chr($src);
        } elseif ($src <= 0x07ff) {
          $dest .= chr(0xc0 | ($src >> 6));
          $dest .= chr(0x80 | ($src & 0x003f));
        } elseif ($src == 0xFEFF) {
          // nop -- zap the BOM
        } elseif ($src >= 0xD800 && $src <= 0xDFFF) {
          // found a surrogate
          return false;
        } elseif ($src <= 0xffff) {
          $dest .= chr(0xe0 | ($src >> 12));
          $dest .= chr(0x80 | (($src >> 6) & 0x003f));
          $dest .= chr(0x80 | ($src & 0x003f));
        } elseif ($src <= 0x10ffff) {
          $dest .= chr(0xf0 | ($src >> 18));
          $dest .= chr(0x80 | (($src >> 12) & 0x3f));
          $dest .= chr(0x80 | (($src >> 6) & 0x3f));
          $dest .= chr(0x80 | ($src & 0x3f));
        } else {
          // out of range
          return false;
        }
      }
      return $dest;
    }
    
    print mb_convert_encoding(
      preg_replace_callback(
        "~\\\\u([1234567890abcdef]{4})~", 'unicode_hex_to_utf8',
        json_encode($response)),
      "ISO-8859-9", "UTF-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to encode an array to json for use with jquery. This is
I am trying to json encode an array,it does encode but i get lots
I have a JSON string (from PHP's json_encode() that looks like this: [{id: 1,
i'm trying to use json_decode to combine a few json objects and then re-encode
I use JSON.NET and I would like to parse the following object which I
I'm trying to use json for my web page's globalization options.. id like to
I have a multidimensional array that looks something like this: ourThing = array( 'id'
So i have this json I got from a previous query: {HUID:1,UIDS:1,2,3,name:home,type:page,cat_id:home} I print
I have am using ajax to retun a array [[int,string],....] in index.json. Here is
Has anyone way around this bug ? echo json_encode(array('url'=>'/foo/bar')); {url:\/foo\/bar} I use Zend_Json and

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.