JavaScriptメモ その5!
・encodeURIComponent(デコードはdecodeURIComponent)による日本語文字のエスケープ(特殊文字にも対応しているため有用らしい)
var a = "おはよう@〜";
var en = encodeURIComponent(a);
console.log(en);
var de = decodeURIComponent(en);
console.log(de);
=>
%E3%81%8A%E3%81%AF%E3%82%88%E3%81%86%EF%BC%A0%E3%80%9C
おはよう@〜
0 件のコメント:
コメントを投稿