#49588 [Opn->Bgs]: json_encode returns null for certain strings

From: Date: Fri, 18 Sep 2009 12:54:42 +0000
Subject: #49588 [Opn->Bgs]: json_encode returns null for certain strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-142515@lists.php.net to get a copy of this message
 ID:               49588
 Updated by:       jani@php.net
 Reported By:      fernando at consultorpc dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         JSON related
 Operating System: Linux/Mac OSX Leopard
 PHP Version:      5.3.0
 New Comment:

PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in
Command line code on line 1


Previous Comments:
------------------------------------------------------------------------

[2009-09-18 12:36:22] fernando at consultorpc dot com

Description:
------------
At my specific case, if a string contains an Euro symbol ( € ),
json_encode will return null for that string.

It might also happens with other special characters.

Reproduce code:
---------------
<?php

$array = array(
        'name' => htmlentities( 'My euro symbol €.' )
);

var_dump( $array );
var_dump( json_encode( $array ) );

Expected result:
----------------
array(1) {
  ["name"]=>
  string(29) "My euro symbol &euro;."
}
string(13) "{"name":"My euro symbol &euro;."}"

Actual result:
--------------
array(1) {
  ["name"]=>
  string(29) "My euro symbol &acirc;?&not;."
}
string(13) "{"name":null}"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49588&edit=1



Thread (8 messages)

« previous php.bugs (#142515) next »