This package is abandoned and no longer maintained. No replacement package was suggested.

Decode/encode JavaScript Unicode escape sequences

v1.1.1 2016-04-25 00:38 UTC

This package is not auto-updated.

Last update: 2019-02-28 23:17:32 UTC


Packagist Packagist Travis Code Climate

This library converts between UTF-8 and JavaScript Unicode escape characters, i.e. 'š' <=> '\u0161'


Add to your composer.json:

    "require": {
        "sandfoxme/unicode-entities": "*"


$s = \SandFoxMe\Misc\UnicodeEntites::decode("K\\u00f3dov\\u00e1n\\u00ed znak\\u016f");
print $s; // "Kódování znaků"

$s = \SandFoxMe\Misc\UnicodeEntites::encode("文字コード");
print $s; // "\u6587\u5b57\u30b3\u30fc\u30c9"

UnicodeEntites::encode returns ASCII string with all non-ASCII characters encoded in JavaScript Unicode notation.

It's a dirty hack! You use json_encode()!

Yes it's a hack :) But it's working and well-tested one, see /tests/


The library is available as open source under the terms of the MIT License.