Apply your JS skills to key Mozilla projects as an MDN Fellow! http://mzl.la/MDNFellowship

mozilla
Your Search Results

    String.prototype.normalize()

    この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。

    This is an experimental technology, part of the Harmony (ECMAScript 6) proposal.
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.

    Summary

    The normalize() method returns the Unicode Normalization Form of a given string (if the value isn't a string, it will be converted to one first).

    Syntax

    str.normalize([form])

    Parameters

    form
    One of "NFC", "NFD", "NFKC", or "NFKD", specifying the Unicode Normalization Form. If omitted or undefined, "NFC" is used.
    • NFC — Normalization Form Canonical Composition.
    • NFD — Normalization Form Canonical Decomposition.
    • NFKC — Normalization Form Compatibility Composition.
    • NFKD — Normalization Form Compatibility Decomposition.

    Throws

    RangeError
    A RangeError is thrown if form isn't one of the values specified above.

    Description

    The normalize() method returns the specified Unicode Normalization Form of the string. It does not affect the value of the string itself.

    Examples

    Example: Using normalize()

    // Initial string
    
    // U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE
    // U+0323: COMBINING DOT BELOW
    var str = '\u1E9B\u0323';
    
    
    // Canonically-composed form (NFC)
    
    // U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE
    // U+0323: COMBINING DOT BELOW
    str.normalize('NFC'); // '\u1E9B\u0323'
    str.normalize();      // same as above
    
    
    // Canonically-decomposed form (NFD)
    
    // U+017F: LATIN SMALL LETTER LONG S
    // U+0323: COMBINING DOT BELOW
    // U+0307: COMBINING DOT ABOVE
    str.normalize('NFD'); // '\u017F\u0323\u0307'
    
    
    // Compatibly-composed (NFKC)
    
    // U+1E69: LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE
    str.normalize('NFKC'); // '\u1E69'
    
    
    // Compatibly-decomposed (NFKD)
    
    // U+0073: LATIN SMALL LETTER S
    // U+0323: COMBINING DOT BELOW
    // U+0307: COMBINING DOT ABOVE
    str.normalize('NFKD'); // '\u0073\u0323\u0307'
    

    Specifications

    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'String.prototype.normalize' in that specification.
    Draft Initial definition.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 34 31 (31) 11 on Windows 10 Preview (Yes) Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported 34 Not supported
    bug 864843
    Not supported Not supported Not supported

    See also

    ドキュメントのタグと貢献者

    Contributors to this page: Mingun, trueorfalse, fscholz, ziyunfei, arai, Havvy, Waldo, realityking
    最終更新者: Mingun,
    サイドバーを隠す