* 仕様書

[REFS[
- [44] [CITE[[[The Unicode Standard]], Version 13.0 - ch02.pdf]], [TIME[2020-03-09T17:53:32.000Z]], [TIME[2020-12-20T08:35:03.323Z]] <https://www.unicode.org/versions/latest/ch02.pdf#G25564>
-- [46] <https://www.unicode.org/versions/latest/ch02.pdf#G14527>
- [35] [CITE[[[The Unicode Standard]], Version 13.0 - ch03.pdf]], [TIME[2020-03-09T17:53:34.000Z]], [TIME[2020-12-20T02:08:18.239Z]] <https://www.unicode.org/versions/latest/ch03.pdf#G2212>
]REFS]

* 符号位置

[36] 
[DFN[[RUBY[符号点][ふごうてん][code point]]]],
[DFN[[RUBY[符号位置][ふごういち][code position]]]]は、
[[符号空間]]中の[[整数]] [SRC[>>44]]、 
[[Unicode]] の場合は
[[Unicode符号空間]]上の任意の値です
[SRC[>>35 D10]]。
すなわち範囲
[ [N[0]], [N[0x10FFFF]] ]
の[[整数]]です。

[37] [CITE[The Unicode Standard]]
は
「code point」
を規定し、
「code position」
は別名としています。
[SRC[>>35 D10]]


[52] 
[[code point]] は [[Unicode]] 系の、 [[code position]] は [[ISO/IEC 10646]]
系の用語です。どちらも同じ意味で、原文の引用以外で使い分ける意味はありません。
[[code point]] の方が広く用いられています。

[53] 
[DFN[codepoint]] と一語にすることもありますが、一般的とまではいえません。


[49] 
[[日本語]]では [[code point]], [[code position]] のどちらも[[符号位置]]と訳すのが一般的です。

[51] 
両者の区別を保存して翻訳するなら[[符号点]]、[[符号位置]]と書き分けることになります。

;; [54] 
[[English]] で一般的なのは [[code point]]、
[[日本語]]で一般的なのは[[符号位置]]と逆転しているのが困りどころ。

[50] 
[DFN[コードポイント]]と[[音訳]]することもままありますが、
[[日本語]]の文脈ではやはり[[日本語]]に訳された用語を使うべきです。


-*-*-

[41] 
[[符号点]]を[[抽象文字]]に関連付けたものを[[符号化済文字]]といいます。

[42] 
[[符号点]]の列を[[符号化済文字列]]といいます。
[CITE[The Unicode Standard]] 
は[[文字]]とは[[符号化済文字]] (≠ [[符号点]])、
[[文字列]]とは[[符号化済文字列]] = [[符号点]]の列としていて、
意味がねじれています。

[43] 
[[Unicode符号点]]から[[サロゲート符号点]]を除外したものが、
[[Unicodeスカラー値]]です。

** 古い HTML 仕様における定義

[11] 古い [[HTML]] 仕様は独自に「[[符号位置]]」という語を定義していました。現在の [[HTML]] 
仕様 ([[HTML]]、[[Web Applications 1.0]]) は独自の定義を含んでいません。

[2]
> 
:[DFN[[RUBYB[[[符号位置]]]@en[code position]]]]:
[[符号化文字集合]]の[[変域]]中の[[整数]]。
符号化文字集合は符号位置を[[文字]]に写像する。

;; [10] [[RFC 1866]], [[ISO‐HTML]] <http://purl.org/NET/ISO+IEC.15445/15445.html#DEFS> 4.5

** IDN2003 における定義

[1]
> [DFN[[RUBY[[[符号位置]]][ふごういち]@en[code point]]]]は、
[[符号化文字集合]]中の[[文字]]に関連付けられた[[整数値]]です。

;; [6] [[RFC 3490]] 2.、
[7] [CITE@en[RFC 3492 - Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)]] 
<http://tools.ietf.org/html/rfc3492#section-2>

** IDN2008 における定義

[9] 
> [DFN[[RUBYB[符号位置]@en[code point]]]]は、[[符号化文字集合]]の[RUBYB[[[符号空間]]]@en[codespace]]中の[[整数]]値です。

;; [8] [CITE@en[RFC 5890 - Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework]] 
<http://tools.ietf.org/html/rfc5890#section-2.1>

** XDM における定義

[12] 
> This document uses the term "code point", sometimes spelt "codepoint" (also known as "character number" or "code position") to mean a non-negative integer that represents a character in some encoding. 

[5] [CITE@EN[XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)]]
<http://www.w3.org/TR/2010/REC-xpath-functions-20101214/#string-types>

* 表記法

[17] [[Unicode]] / [[UCS]] の[[符号位置]]は、 [CODE[[[U+]]]] や [CODE[[[U-]]]]
によって[[符号位置]]を表します。

[45] 
[CODE[U+]] の[[符号点]]の表記と[[文字の名前]]を並べて、
「[CODE[U+0061]] [CODE(charname)@en[LATIN SMALL LETTER A]]」
のようにも表記します。
[SRC[>>44]]

[19] [[7ビット符号]]や[[8ビット符号]]の[[ビット組合せ]]は、 [CODE[/]]
によって4ビットずつの[[十進数]]を組み合わせて表記して表します。

[18] [[JIS X 0218]] は[[短縮識別名称]]を規定していました。

[4] [[エスケープ]]も参照。

* 符号点型

[38] 
[DFN[[RUBY[符号点型][ふごうてんがた][code point type]]]]
([DFN[[RUBY[基本型][きほんがた][basic type]]]] [SRC[>>46]])
は、
[[符号点]]の7つの基礎的な[[クラス]]のいずれかです。
[SRC[>>35 D10a]]

[FIG(table)[ [39] [[符号点型]]
:t: [[符号点型]] ([[基本型]])
:gc: [[General Category]]
:ac: [[抽象文字]]割当
:cp: [[符号点]]割当状態

:t:[[図形][図形文字]]
:gc: [CODE[L][Letter]], [CODE[M][Combining Mark]], [CODE[N][Number]], 
[CODE[P][Punctuation]], [CODE[S][Symbol]], [CODE[Zs]]
:ac: [[割当済][割当済文字]]
:cp: [[割当済][割当済符号点]]

:t:[[書式][書式文字]]
:gc: [CODE[Cf]], [CODE[Zl]], [CODE[Zp]]
:ac: [[割当済][割当済文字]]
:cp: [[割当済][割当済符号点]]

:t:[[制御][制御文字]]
:gc:[CODE[Cc]]
:ac: [[割当済][割当済文字]]
:cp: [[割当済][割当済符号点]]

:t:[[私用][私用文字]]
:gc: [CODE[Co]]
:ac: [[割当済][割当済文字]]
:cp: [[割当済][割当済符号点]]

:t:[[サロゲート]]
:gc: [CODE[Cs]]
:ac: 割当不可
:cp: [[割当済][割当済符号点]]

:t:[[非文字]]
:gc: [CODE[Cn]]
:ac: [[未割当済]]
:cp: [[割当済][割当済符号点]]

:t:[[予約済][予約済符号点]]
:gc: [CODE[Cn]]
:ac: [[未割当済]]
:cp: [[未割当済][未割当済符号点]]
]FIG]

[40] すべての[[符号点]]は、いずれか1つの[[符号点型]]に属します。

* 関連

[3]  「[[文字]]」、「[[符号位置]]」 (「[[code point]]」、「[[code position]]」)、「[[符号単位]]」
などはしばしば混用されます。

[13] [[Unicodeスカラー値]]は [[Unicode]] における[[符号位置]]を表す語です。

[55] [[Unicodeの符号空間]]

* 歴史

[14] [CITE@EN[XPath and XQuery Functions and Operators 3.0]]
( ([TIME[2014-04-08 07:02:07 +09:00]] 版))
<http://www.w3.org/TR/xpath-functions-3/#codepoint>

[15] [CITE@en[Character Model for the World Wide Web 1.0: Fundamentals]]
( ([TIME[2005-02-15 14:24:00 +09:00]] 版))
<http://www.w3.org/TR/charmod/#def-CCS>

[16] [CITE@en[RFC 6797 - HTTP Strict Transport Security (HSTS)]] ([TIME[2014-06-02 05:16:10 +09:00]] 版) <http://tools.ietf.org/html/rfc6797#section-4>

>
:codepoint:
is a colloquial contraction of Code Point, which is any value in
the Unicode codespace; that is, the range of integers from 0 to
10FFFF(hex) [Unicode].


[FIG(quote)[
[FIGCAPTION[
[20] [CITE[perldelta - search.cpan.org]]
( ([TIME[2016-05-10 17:56:10 +09:00]]))
<http://search.cpan.org/~rjbs/perl-5.24.0/pod/perldelta.pod>
]FIGCAPTION]

> Using code points above the platform's IV_MAX is now deprecated
> Unicode defines code points in the range 0..0x10FFFF. Some standards at one time defined them up to 2**31 - 1, but Perl has allowed them to be as high as anything that will fit in a word on the platform being used. However, use of those above the platform's IV_MAX is broken in some constructs, notably tr///, regular expression patterns involving quantifiers, and in some arithmetic and comparison operations, such as being the upper limit of a loop. Now the use of such code points raises a deprecation warning, unless that warning category is turned off. IV_MAX is typically 2**31 -1 on 32-bit platforms, and 2**63-1 on 64-bit ones.

]FIG]


[21] [CITE@en[Editorial: start using the Infra Standard]]
([[annevk]]著, [TIME[2016-11-18 20:21:54 +09:00]])
<https://github.com/whatwg/encoding/commit/a26f76889bf393999e9caad84a3647ab09c39e09>

[22] [CITE@en[Change Unicode \u -> U+ (Fix #127)]]
([[garykac]]著, [TIME[2016-12-17 12:11:30 +09:00]])
<https://github.com/w3c/uievents/commit/2cfeb1f351f18e9eb3318563267b87b3e2e8f3f3>

[23] [CITE@en[Convert 'codepoint' to 'code point' to match the Unicode Standard]]
([[vkatsikaros]]著, [TIME[2017-01-16 23:36:01 +09:00]])
<https://github.com/w3c/webdriver/commit/a230a6144089c8a3558ea7101d2b4adb51531aa5>

[24] [CITE@en[XQuery and XPath Data Model 3.1]]
([TIME[2017-03-20 07:26:25 +09:00]])
<https://www.w3.org/TR/2017/REC-xpath-datamodel-31-20170321/#dt-codepoint>

[25] [CITE@EN[XPath and XQuery Functions and Operators 3.1]]
([TIME[2017-03-21 16:02:06 +09:00]])
<https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/#codepoint>

[26] [CITE@en[Improve representation guidelines for bytes and code points]]
([[annevk]]著, [TIME[2017-03-23 22:25:17 +09:00]])
<https://github.com/whatwg/infra/commit/543b2c48b6e1babb50d77e5a3ba5b86be8b56eb9>

[27] [CITE@en[Define character as alias for code point]]
([[annevk]]著, [TIME[2017-03-27 16:14:19 +09:00]])
<https://github.com/whatwg/infra/commit/034569bc45594f30a903cb348f9fde35c2a27609>

[28] [CITE@en[Define character as alias for code point by annevk · Pull Request #104 · whatwg/infra]]
([TIME[2017-03-28 18:34:52 +09:00]])
<https://github.com/whatwg/infra/pull/104>

[29] [CITE@en[Editorial: format bytes and code points per Infra]]
([[annevk]]著, [TIME[2017-03-28 21:14:42 +09:00]])
<https://github.com/whatwg/url/commit/91cb2aa532bc2b217e6237d23649aed0d2c566bb>

[30] [CITE@en[Editorial: let code point and friends be defined by Infra]]
([[annevk]]著, [TIME[2017-03-29 17:47:15 +09:00]])
<https://github.com/whatwg/html/commit/59595d9c2ccadb9332c15048be5d30174532ee70>

[31] [CITE@en[Deal with the parentheses exception for code point/byte display]]
([[annevk]]著, [TIME[2017-03-30 13:25:34 +09:00]])
<https://github.com/whatwg/infra/commit/a743dbd7f1c9d6200d8eaae127aeeb85a701fb02>

[32] [CITE@en['''['''css-syntax''']''' Remove 'code point' and 'surrogate code point' in favor …]]
([[tabatkins]]著, [TIME[2017-06-10 03:59:51 +09:00]])
<https://github.com/w3c/csswg-drafts/commit/320a990184a331057a56a17cdf627fee81bdc5d3>

[FIG(quote)[
[FIGCAPTION[
[33] [CITE@EN[XSL Transformations (XSLT) Version 3.0]]
([TIME[2017-06-06 21:59:56 +09:00]])
<https://www.w3.org/TR/2017/REC-xslt-30-20170608/#analyze-string>
]FIGCAPTION]

> The term character, here as elsewhere in this specification, means a Unicode codepoint. 

]FIG]


[34] [CITE@en[Allow decimals with no leading 0 as the time in refresh <meta>]]
([[domenic]]著, [TIME[2017-07-22 06:10:04 +09:00]])
<https://github.com/whatwg/html/commit/b8a34e302cdf0289f5403a02905629bb358519a6>

[47] [CITE@en-us[UTS #18: Unicode Regular Expressions]], [TIME[2022-02-08T14:02:12.000Z]], [TIME[2022-11-13T03:26:33.797Z]] <https://unicode.org/reports/tr18/#character_ranges>

>For the purpose of regular expressions, in this document the terms “character” and “code point” are used interchangeably. 

[48] [CITE@en[Web Applications 1.0 r6650 Define 'Unicode code point'.]]
( ([TIME[2011-10-07 08:34:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=6649&to=6650>

