String normalize()
String.prototype.normalize() は Unicode 正規化形式(NFC, NFD, NFKC, NFKD)に変換します。濁点付き文字の比較や全角半角の統一に使用します。
概要
String.prototype.normalize() は Unicode 正規化形式(NFC, NFD, NFKC, NFKD)に変換します。濁点付き文字の比較や全角半角の統一に使用します。
対応ブラウザ
| 機能 | デスクトップ | モバイル | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 34 | 12 | 31 | 10 | 34 | 10 | |
基本構文
JAVASCRIPT
// Unify the two representations of 'ga'
const a = '\u304C'; // ga (single character)
const b = '\u304B\u3099'; // ka + dakuten
a === b; // false
a.normalize() === b.normalize(); // true ライブデモ
dotcharacter. positiveizationcomparison
" that " 1character in table or " or +dot" in table or positiveization in keep consistentcomparison..
プレビュー全画面表示
full-width / half-width. consistent (NFKC)
full-width. numbercharacter half-width to, symbol standard shape notation to positiveization..
プレビュー全画面表示
Search time. notation
differentizationshape notation. Character in also, positiveization and in positivematchng in..
プレビュー全画面表示
実務での使いどころ
-
String normalize() の活用
Unicode 正規化を行うメソッド。同じ文字の異なるエンコーディングを統一できる。
注意点
- 特になし。すべての主要ブラウザで安定して動作する。
アクセシビリティ
- JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。
参考リンク
Powered by web-features