define('MY_JSON_SLICE', 1);
define('MY_JSON_IN_STR', 2);
define('MY_JSON_IN_ARR', 3);
define('MY_JSON_IN_OBJ', 4);
define('MY_JSON_IN_CMT', 5);
define('MY_JSON_LOOSE_TYPE', 16);
define('MY_JSON_SUPPRESS_ERRORS', 32);
class MY_JSON
{
function MY_JSON($use = 0)
{
$this->use = $use;
}
function utf162utf8($utf16)
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch (true) {
case ((0x7F & $bytes) == $bytes):
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
return chr(0xE0 | (($bytes >> 12) & 0x0F)) . chr(0x80 | (($bytes >> 6) & 0x3F)) . chr(0x80 | ($bytes & 0x3F));
}
return '';
}