OMG, I need to take a rest, sorry for this, here it goes again; the
about JSON_INVALID_UTF8_IGNORE opinion is the same, but previous code
was wrong

Code:

<?php

var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }", true, 512),
json_last_error_msg());
var_dump("------------");
var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }", true, 512,
JSON_INVALID_UTF8_IGNORE), json_last_error_msg());

Result:

NULL
string(56) "Malformed UTF-8 characters, possibly incorrectly encoded"
string(12) "------------"
array(1) { ["ab"]=> string(5) "dummy" }
string(8) "No error"

Saying so, now ... yes I support and think is NEEDED the usage of the
JSON_INVALID_UTF8_IGNORE , as json_validate() result goes in the same
direction with json_decode(). I think we need to have this flag.

RFC: https://wiki.php.net/rfc/json_validate
Implementation: https://github.com/php/php-src/pull/9399

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to