escape() and unescape()
The escape() 関数は、特定の文字を 16 進数のエスケープシーケンスで置き換えた新しい文字列を計算します。
対応ブラウザ
ライブデモ
Encode with escape and encodeURIComponent
Compare the legacy functions with modern URL-safe encoding.
JavaScript
出力
「実行」ボタンを押してください
Decode encoded text
Restore the original string from an escaped sequence.
JavaScript
出力
「実行」ボタンを押してください
Handle non-ASCII characters
See why escape/unescape are legacy APIs for Unicode text.
JavaScript
出力
「実行」ボタンを押してください
実務での使いどころ
-
escape() and unescape() の活用
The escape() 関数は、特定の文字を 16 進数のエスケープシーケンスで置き換えた新しい文字列を計算します。
注意点
- 一部のブラウザでのみ対応。使用前にブラウザサポートを確認すること。
アクセシビリティ
- JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。