javascript escape 인코딩 php로 디코딩 하기

PHP/팁앱테크 2013. 1. 13. 10:26

// script /======================================================

< script >

var title;

title =escape("ㅇㄹㄴ#$#%2ㅇ,ㄹㅇ남; ㄹㅇㄴㅁ");

< /script >


// php /=========================================================

< ?php

function js_unescape($s) {

    $s= preg_replace('/%u(....)/', '&#x$1;', $s);

    $s= preg_replace('/%(..)/', '&#x$1;', $s);

    return html_entity_decode($s, ENT_COMPAT, 'utf-8');

}


$title = js_unescape($_REQUEST['title']);

? >