Getting strange text results back such as \u25cf

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Getting strange text results back such as \u25cf

Post by Weirdan »

That works for me without a hitch as well.
alzika
Forum Newbie
Posts: 11
Joined: Sun Aug 21, 2011 6:23 pm

Re: Getting strange text results back such as \u25cf

Post by alzika »

Don't know what to say. I'm surprised. Is this a config issue? Something I need to change in php.ini?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Getting strange text results back such as \u25cf

Post by Weirdan »

json extension has no configuration settings. What does 'php --re json' return?
alzika
Forum Newbie
Posts: 11
Joined: Sun Aug 21, 2011 6:23 pm

Re: Getting strange text results back such as \u25cf

Post by alzika »

Code: Select all

Extension [ <persistent> extension #32 json version 1.2.1 ] {

  - Constants [12] {
    Constant [ integer JSON_HEX_TAG ] { 1 }
    Constant [ integer JSON_HEX_AMP ] { 2 }
    Constant [ integer JSON_HEX_APOS ] { 4 }
    Constant [ integer JSON_HEX_QUOT ] { 8 }
    Constant [ integer JSON_FORCE_OBJECT ] { 16 }
    Constant [ integer JSON_NUMERIC_CHECK ] { 32 }
    Constant [ integer JSON_ERROR_NONE ] { 0 }
    Constant [ integer JSON_ERROR_DEPTH ] { 1 }
    Constant [ integer JSON_ERROR_STATE_MISMATCH ] { 2 }
    Constant [ integer JSON_ERROR_CTRL_CHAR ] { 3 }
    Constant [ integer JSON_ERROR_SYNTAX ] { 4 }
    Constant [ integer JSON_ERROR_UTF8 ] { 5 }
  }

  - Functions {
    Function [ <internal:json> function json_encode ] {

      - Parameters [2] {
        Parameter #0 [ <required> $value ]
        Parameter #1 [ <optional> $options ]
      }
    }
    Function [ <internal:json> function json_decode ] {

      - Parameters [3] {
        Parameter #0 [ <required> $json ]
        Parameter #1 [ <optional> $assoc ]
        Parameter #2 [ <optional> $depth ]
      }
    }
    Function [ <internal:json> function json_last_error ] {

      - Parameters [0] {
      }
    }
  }
}
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Getting strange text results back such as \u25cf

Post by AbraCadaver »

Are you using Linux, Mac or Windows? If Linux, what shell? Don't know if it matters, but I just tried it on Windows and I got odd characters, just not the ones you got.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Getting strange text results back such as \u25cf

Post by s.dot »

I had a try as well. Didn't get the characters you are getting but I did get odd characters like AbraCadaver (command line on windows). Tried a bunch of options with stream_context_create() but couldn't figure it out!

This one is intriguing.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Getting strange text results back such as \u25cf

Post by AbraCadaver »

It is worth noting that if you recurse through the array after decode, all array elements are ASCII except the $data['results'][0]['description'] which is UTF-8. That is most likely the problem that your OS or shell is not handling the UTF-8 encoding.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
alzika
Forum Newbie
Posts: 11
Joined: Sun Aug 21, 2011 6:23 pm

Re: Getting strange text results back such as \u25cf

Post by alzika »

Using linux, centos specifically.

Any idea how to fix the UTF-8 encoding problem?

This just seems really odd to me.
Post Reply