[1] [[Unicode]] の [DFN[[ABBR[NFC]]]] ([DFN[正規化形 C]])
は、 <http://www.unicode.org/reports/tr15/#Normalization_Form_C>
で規定されている Unicode 文字列の正規形のひとつです。

NFC は、大まかには、[[正準分解]]を行った後に[[正準結合]]を行います。
これによって、ひとつの[[文字]]に複数種類の表現が対応するときに、 ''(Unicode 的に)'' 等価でもっとも短い形にすることができます。

[17] [[Unicode]] の[[正規形]]を用いるほとんどの場面では、 [[NFC]] が採用されています。

* 仕様書

[REFS[
- [39] [[Unicode Standard]] <http://www.unicode.org/versions/latest/ch03.pdf>
]REFS]

* 定義

[2] 詳しい定義はこうです。
(実装はこれと同じ結果が得られるなら、他の方法を使ってもかまいません。)

= 原始文字列 [VAR[S]] の正準分解を、
実装が対応している最新版の [[UCD]] の[[正準写像]]に従って生成する。
= 分解中の最初から最後までのそれぞれの文字 [VAR[C]]
について、次の操作を繰り返す。
== [VAR[C]] が最後の[[開始子]] [VAR[L]] から[[妨害]]されておらず、 [VAR[L]] と[[初等結合]]できるなら、
[VAR[L]] を合成 [VAR[L-C]] で置換し、 [VAR[C]] を削除する。
= これによって得られた文字列 [VAR[S']] が [VAR[S]] の
[ABBR[NFC]] である。

[5] 仕様書:
- [UTR #15-18] [CITE[UTR #15: Unicode Normalization]] 
<http://www.unicode.org/unicode/reports/tr15/tr15-18.html>
- [Cor. #2] [CITE[Corrigendum #2: Yod with Hiriq Normalization]] 
<http://www.unicode.org/versions/corrigendum2.html>

* 文脈

[32] 一般論として、 [[Unicode文字列]]は [[NFC]] とするのが好ましいと考えられています。

[33] しかし、[[文字列]]の[[生成者]]は [[NFC]] を使うべきですが、
[[消費者]]は勝手に[[正規化]]するべきではないとされています。

[50] 
実際には、[[正規化]]は破壊的な操作なので、[[情報交換]]では使うべきではありません。
[[プロトコル]]が要求する場合だけに限るべきです。
[SEE[ [[正規化]] ]]

* NFC によるデータ破壊

[57] 
[[NFC]] は破壊的操作です。データが不可逆に変化します。
恒久的に保存される、または外部に送信されるオリジナルデータに適用するべきではありません。
[SEE[ [[Unicode正規化]] ]]

* 変種

[56] [[KS X 1026-1]]

[66] 
[CITE@en[Encode-MAB2/lib/Encode/MAB2.pm at master · andk/Encode-MAB2 · GitHub]], [TIME[2025-06-26T13:35:50.000Z]] <https://github.com/andk/Encode-MAB2/blob/master/lib/Encode/MAB2.pm#L102>


* デマ

[64] [CITE@ja[普通のUnicodeはNFCなのか – ものかの]], [TIME[2023-05-23T13:47:00.000Z]], [TIME[2023-05-24T11:34:03.622Z]] <https://tama-san.com/unicode-nfc/>

>「普通のUnicodeはNFC」というおかしな風説が流布されています。[SNIP[]]

>「普通のUnicodeはNFC」と同様の風説に「WindowsはNFC」があります。


* NFC を採用するプロトコル

[34] [[Web]] において [[NFC]] が使われる場面は、次の通りです。
[FIG(list)[
- [36] [[ドメイン]]では、
-- [[Unicode IDNA互換性処理]]で [[NFC]] が実行されます。
-- [[妥当性基準]]で [[NFC]] かどうかの検査があります。
- [37] [[XML]] では、[[著者]]の要件の一部に [[NFC]] が組み込まれています。
- [38] [[JavaScript]] の [CODE(DOMm)@en[normalize]] [[メソッド]]は、
[[NFC]] にも対応しています。
- [49] [[N3]]
- [51] [[RDFリテラル]]
]FIG]

[35] その他色々な場面で [[NFC]] が使われることがあります。

[65] [[ファイル名]]も参照。

[58] 
[[Unicode正規表現]]は実装が入力に適用してもいいとしています。

[4]
第18版 ([[Unicode 3.0]] に対応) [SRC[UTR #15-18]] を採用する応用仕様:
- [CITE[XML Encryption Syntax and Processing]] 
<http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/#sec-Processing-Encryption>
([Q['''[[MUST]]''']])

[3] 第18版 ([[Unicode 3.0]] に対応) [SRC[UTR #15-18]] と正誤表2
[SRC[Cor. #2]] を採用する応用仕様:
- [CITE[XML Encryption Syntax and Processing]] 
<http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/#sec-EncryptedType>
([Q['''[[SHOULD]]''']]) 

[6] 最新版を採用する応用仕様:
- [CITE@en[Web Forms 2.0]] 
<http://www.whatwg.org/specs/web-forms/current-work/#form-submission>
([Q@en['''[[SHOULD]]''']])

[7]
[[RFC 5335]] ([[電子メイル]][[頭部]]の[[国際化]]) は、
[[RFC 5189]] を参照しつつ、 [[NFC]] を[['''推奨''']]しています。
([[名無しさん]])


[8]
([[RFC 5335]] 4.1)

[9] [CITE[NFC FAQ ‎(Macchiato)‎]] ([TIME[2009-03-02 11:37:59 +09:00]] 版) <http://www.macchiato.com/unicode/nfc-faq>

>This really depends on the kind of text involved. For example, according to data at Google:
- ~99.98% of web HTML page content characters are definitely NFC.
- Content means after discarding markup, and doing entity resolution.
- ~99.9999% of web HTML page markup characters are definitely NFC.
-- Because so much of markup is plain ASCII.
>
Of course, this represents data from just a sample of the web (in this case, the total characters in 700,000,000 documents as of January 23, 2009). Proportions may differ somewhat depending on which sample is chosen, and may change over time as the percentage of languages on the web changes. Normalization is important for some languages like  Vietnamese and other languages of South and Southeast Asia even though their percentage of total text is small.

[10] [CITE[ECMAScript Language Specification (HTML version)]] ([TIME[2009-04-03 04:43:48 +09:00]] 版) <http://bclary.com/2004/11/07/#a-6>

[11] [[ES3]] は [[UTR#15]] の「1998年版」 ([[Unicode 2.1]] 世代) を[[引用]]し、
[[ソース・テキスト]]は [[NFC]] で[[正規化]]されていることが期待されているが、
[[適合ECMAScript実装]]が[[正規化]]することは[[必須]]ではない、としています [SRC[>>10]]。

;; [[必須]]ではない、ということはしてもよい、ということになります。

- [60] [CITE@en[[[RFC 4329]]: Scripting Media Types]], [TIME[2022-11-22T08:26:05.000Z]] <https://www.rfc-editor.org/rfc/rfc4329.html#page-8>
- [59] [CITE@en[[[RFC 9239]]: Updates to ECMAScript Media Types]], [[Matthew A. Miller]], [TIME[2022-11-22T08:25:55.000Z]] <https://www.rfc-editor.org/rfc/rfc9239#section-5>

[61] [[RFC 4329]] は [[JavaScript]] の[[プログラム]]は [[NFC]]
であることが[RUBYB[期待される][expected]]、
[[正規化]]されていないとセキュリティー的危険が伴うので注意[MUST[必須]]、
としていました [SRC[>>60]]。
16年越しに改訂された [[RFC 9239]] もそのままでした [SRC[>>59]]。

[62] 明記されていませんが、期待されるとは [[ES3]] に従ったものかと思われます。

[12] [CITE@en[Web Applications 1.0 r7195     Revert r6810 since it doesn't work.]]
( ([TIME[2012-07-20 13:31:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7194&to=7195>

[13] [CITE@en-US[''''''[''''''DRAFT'''''']''''''Near Field Communications Working Group Charter]]
( ([TIME[2012-09-21 20:23:24 +09:00]] 版))
<http://www.w3.org/2012/05/nfc-wg-charter.html>

[14] [CITE@en[XML Encryption Syntax and Processing Version 1.1]]
( ([TIME[2013-04-13 02:02:32 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/#sec-EncryptedType>

[15] [CITE@en[XML Encryption Syntax and Processing Version 1.1]]
( ([TIME[2013-04-13 02:02:32 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/#sec-Processing-Encryption>

[16] [CITE@en[XML Signature Syntax and Processing Version 1.1]]
( ([TIME[2013-04-16 23:47:22 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmldsig-core1-20130411/#sec-c14nAlg>

[18] [CITE@en[XSLT and XQuery Serialization 3.0]]
( ([TIME[2014-04-07 23:19:15 +09:00]] 版))
<http://www.w3.org/TR/xslt-xquery-serialization-3/#uri-escaping>

[19] [CITE@en[Character Model for the World Wide Web 1.0: Normalization]]
( ([TIME[2012-04-27 11:15:23 +09:00]] 版))
<http://www.w3.org/TR/charmod-norm/#sec-UnicodeNormalized>

[20] [CITE@en[Extensible Markup Language (XML) 1.1 (Second Edition)]]
( ([TIME[2006-09-29 19:02:09 +09:00]] 版))
<http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-CharNorm>

[21] [[Charmod]] で[DFN[[RUBYB[[[Unicode正規化済み]]]@en[Unicode-normalized]]]]とは [[NFC]]
のことをいいます [SRC[>>19, >>20]]。 [[NFC]] と[[マーク付け言語]]の構造の組み合わせにより[[取り込み正規化済み]]、
[[完全正規化済み]]という正規化の形が定義されています。 [[XML 1.0]] と [[XML 1.1]]
は[[構文解析対象実体]]が[[完全正規化済み]]である[['''べき''']]としています。


[22] [CITE@en[RFC 5335 - Internationalized Email Headers]]
( ([TIME[2014-03-09 12:10:16 +09:00]] 版))
<http://tools.ietf.org/html/rfc5335#section-4.1>

[23] [CITE@en[RFC 6532 - Internationalized Email Headers]]
( ([TIME[2014-03-09 10:33:13 +09:00]] 版))
<http://tools.ietf.org/html/rfc6532#section-3.1>

[24] [[RFC 6570]] [[URI Template]] は [[Unicode 6.0.0]] [[NFC]] を採用しています。

[25] [[RFC 5198]] [[Net-Unicode]]

[26] [CITE@en[RFC 7542 - The Network Access Identifier]]
([TIME[2015-05-02 05:20:57 +09:00]] 版)
<https://tools.ietf.org/html/rfc7542#section-2.1>

[27] [[基本認証]]の [CODE(HTTP)@en[[[charset=""]]]] の値 [CODE(charset)@en[[[UTF-8]]]]

[FIG(quote)[
[FIGCAPTION[
[28] [CITE@en[RFC 7542 - The Network Access Identifier]]
([TIME[2015-10-18 15:17:56 +09:00]] 版)
<https://tools.ietf.org/html/rfc7542#section-2.1>
]FIGCAPTION]

> Strings that are not Normal Form Composed (NFC)
>    are not valid NAIs and SHOULD NOT be treated as such.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[29] [CITE[Open Publication Structure (OPS) 2.0.1 v1.0]]
([TIME[2015-09-08 04:50:12 +09:00]] 版)
<http://www.idpf.org/epub/20/spec/OPS_2.0_latest.htm#Section1.3.6>
]FIGCAPTION]

> To aid Reading Systems in implementing consistent searching and sorting behavior it is required that Unicode Normalization Form C (NFC) be used

]FIG]


[FIG(quote)[
[FIGCAPTION[
[30] [CITE@en[Model for Tabular Data and Metadata on the Web]]
([TIME[2015-12-03 19:28:42 +09:00]] 版)
<http://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#encoding>
]FIGCAPTION]

> CSV files should be encoded using UTF-8, and should be in Unicode Normal Form C as defined in '''['''UAX15''']'''. 

]FIG]


[FIG(quote)[
[FIGCAPTION[
[31] [CITE@en[RFC 7564 - PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols]]
([TIME[2015-12-21 04:49:41 +09:00]] 版)
<https://tools.ietf.org/html/rfc7564#section-5.2.4>
]FIGCAPTION]

> In accordance with '''['''RFC5198''']''', normalization form C (NFC) is
>    RECOMMENDED.

]FIG]


[40] [CITE@en[XSLT and XQuery Serialization 3.1]]
([TIME[2017-03-20 12:35:18 +09:00]])
<https://www.w3.org/TR/2017/REC-xslt-xquery-serialization-31-20170321/#uri-escaping>

[41] [CITE@en[159891 – '''['''encoding''']''' Support for GB18030]]
([TIME[2017-05-12 11:23:12 +09:00]])
<https://bugs.webkit.org/show_bug.cgi?id=159891>

[42] [CITE[XLIFF Version 2.0]]
([TIME[2014-08-06 01:00:00 +09:00]])
<http://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html#slr_storage>

[FIG(quote)[
[FIGCAPTION[
[43] [CITE@en[Dropbox - Core API - endpoint reference]]
([TIME[2017-05-26 00:23:53 +09:00]])
<https://www.dropbox.com/developers-v1/core/docs>
]FIGCAPTION]

> Every string passed to and from the Dropbox API needs to be UTF-8 encoded. For maximum compatibility, normalize to Unicode Normalization Form C (NFC) before UTF-8 encoding.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[44] [CITE@en[RFC 8162 - Using Secure DNS to Associate Certificates with Domain Names for S/MIME]]
([TIME[2017-06-01 08:15:21 +09:00]])
<https://tools.ietf.org/html/rfc8162#section-3>
]FIGCAPTION]

>  If the local-part contains any non-ASCII characters, it SHOULD be
>        normalized using the Unicode Normalization Form C from '''['''UNICODE''']'''.
>        Recommended normalization rules can be found in Section 10.1 of
>        '''['''RFC6530''']'''.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[45] [CITE@en-us[UTS #22: CharMapML]]
([TIME[2017-06-01 07:35:01 +09:00]])
<http://www.unicode.org/reports/tr22/tr22-8.html#att_u>
]FIGCAPTION]

> Where possible, this should be in Normalization Form C.

]FIG]


[46] [CITE@en[RFC 5280 - Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile]]
([TIME[2018-08-26 16:15:03 +09:00]])
<https://tools.ietf.org/html/rfc5280#section-4.2.1.4>

[47] [CODE[rdf:XMLLiteral]]

[48] [CITE@en[215970 – Remove NFC normalization when submitting forms and encoding URL queries and fix EUC-JP encoding]]
([TIME[2020-08-31T02:44:10.000Z]])
<https://bugs.webkit.org/show_bug.cgi?id=215970>

[FIG(quote)[
[FIGCAPTION[
[52] [CITE@ja[ヘルプ:異体字 - Wikisource]]
([TIME[2021-07-25T13:55:22.000Z]], [TIME[2021-08-08T13:55:56.900Z]])
<https://ja.wikisource.org/wiki/%E3%83%98%E3%83%AB%E3%83%97:%E7%95%B0%E4%BD%93%E5%AD%97#%E3%83%97%E3%83%AC%E3%83%93%E3%83%A5%E3%83%BC%E3%83%BB%E4%BF%9D%E5%AD%98%E6%99%82%E3%81%AB%E5%88%A5%E3%81%AE%E5%AD%97%E4%BD%93%E3%81%AB%E5%A4%89%E3%82%8F%E3%82%8B%E6%96%87%E5%AD%97%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99>
]FIGCAPTION]

> 入力した文字がCJK互換漢字(U+F900 - U+FAFF)及びCJK互換漢字補助(U+2F80 - U+2FA1)(以下まとめてCJK互換漢字と呼びます)の場合、プレビュー・保存等を行った場合、MediaWikiの仕様により、UnicodeのC型正規化(NFC)を行い、CJK統合漢字に分解(変換)されます。例えば「神」と入力した場合、プレビューや保存をすると「神」に正規化されます。

]FIG]


[FIG(quote)[
[FIGCAPTION[
[53] [CITE@ja[Non-Cognate 互換漢字一覧表]]
([TIME[2011-09-07T13:50:23.000Z]], [TIME[2021-08-09T04:13:34.882Z]])
<http://kanji-database.sourceforge.net/variants/non-cognates.html>
]FIGCAPTION]

> 本表は、大漢和辞典・康煕字典などで別字(non-cognate)とされているUCS互換漢字の一覧を示します。

]FIG]

[54] [CITE@en[hcl/spec.md at main · hashicorp/hcl · GitHub]], [TIME[2021-09-22T03:25:21.000Z]] <https://github.com/hashicorp/hcl/blob/main/spec.md#primitive-types>

[[HCL]] は string (文字列) 型の equal (等価性) の判定に [[NFC]] を採用。

[55] [CITE@EN-US[eXtensible Access Control Markup Language (XACML) Version 3.0 Plus Errata 01]], [TIME[2017-07-12T16:00:00.000Z]], [TIME[2021-09-29T03:02:26.217Z]] <http://docs.oasis-open.org/xacml/3.0/errata01/os/xacml-3.0-core-spec-errata01-os-complete.html#_Toc297001140>


[63] 
[[Canonical JSON (OLPC)]]