PHP: convert javascript escape string to CP1251


This function can convert javascript escape string to CP1251:

function je2cp1251($jed)
{
    return preg_replace("/(\\\|%)u([0-9A-F]{4})/e", "html_entity_decode('&#x\\2;',ENT_QUOTES,'cp1251')", $jed);
}

Example 2:

$encoded = "%u0E88%u0EB0%u0E99%u0EB2%u0E99%u0EB8%u0E81%u0EBB%u0EA1%u0E9E%u0EB4%u0EC0%u0EAA%u0E94";
echo je2cp1251($encoded);

result:
ຈະນານຸກົມພິເສດ

Read more: PHP: convert javascript escape string to UTF8

Related Post

, ,

No comments yet.

Leave a Reply