/
647.txt
100 lines (72 loc) · 4.58 KB
/
647.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
[1] [DFN[[[オクテット列]]]] ([DFN[[[octet sequence]]]], [DFN[[[octet stream]]]]) は、
[[オクテット]]の[[列]]です。
[DFN[[RUBYB[[[バイト列]]]@en[byte sequence]]]]は、[[バイト]]の[[列]]です。
ほとんどの場合、これらは交換可能な用語と考えられています。
;; [2] 厳密には[[オクテット]]と[[バイト]]は異なりますが、
現代においては[[バイト]]は8[[ビット]]と同義とされることがほとんどなので、
[[オクテット列]]と[[バイト列]]は同義になります。
* 仕様書
[REFS[
- [14] [CITE[MIME Sniffing Standard]] ([TIME[2016-03-05 01:29:10 +09:00]] 版) <https://mimesniff.spec.whatwg.org/#byte-sequence>
]REFS]
* 意味
[15] [DFN[[RUBYB[バイト列][byte sequence]]]]は、
1つ[[以上]]の[[バイト]]の[[リスト]]であって、
最初の[[バイト]]の位置と最後の[[バイト]]の位置が曖昧なく識別できるものです。
[SRC[>>14]]
;; [16] この定義だと[[空バイト列]]は[[バイト列]]でないことになります。
* 文字列とオクテット列
[3] 歴史的に[[オクテット列]]/[[バイト列]]と[[文字列]]は同義または類義と考えられていた場面もありますが、
本来両者は別のものです。
[6] 近年の[[プログラミング言語]]やデータ交換形式などでは[[バイト列]]と[[文字列]]を区別するケースが増えていますが、
かつては同一視するのが一般的でした。
[EG[
[7] 例えば[[C言語]]では普通 [CODE[[[char]]]] [[型]]は8ビットの[[符号無し整数]]を表しますが、
[[文字]]1つを表すためにも使われています。
]EG]
[EG[
[9] [[Perl]] には [[utf8フラグ]]のある[[文字列]]と、ない[[バイト列]]があります。
ただし両者間は[[暗黙の型変換]]があり、 0x00-0xFF の範囲では両者の区別が曖昧です。
]EG]
[EG[
[8] [[JavaScript]] には長らく[[文字列]]の[[型]] [CODE(JS)@en[[[String]]]] しかありませんでしたが、
[[ES6]] で[[バイト列]]のための [[TypedArray]] が追加されました。
]EG]
[23] [[ASCII文字列]], [[同型符号化]], [[同型復号]]も参照。
* MIME 型
[4] 他に適当な[[MIME型]]が無い場合、 [CODE(MIME)@en[[[application/octet-stream]]]]
を使うことになっています。
* 歴史
[5] [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/#sec-Strings>
[10] [CITE@en[Bug 26499 – Improve the definition of 'byte sequence' to make it less ta... · 6936e73 · whatwg/mimesniff]]
( ([TIME[2014-09-21 13:15:20 +09:00]] 版))
<https://github.com/whatwg/mimesniff/commit/6936e7323b7bbff4f1f047bfa50b06c8a259889b>
[11] [CITE@en[Integrate Fetch into HTML · whatwg/html@7c5555a]]
([TIME[2015-09-18 17:52:46 +09:00]] 版)
<https://github.com/whatwg/html/commit/7c5555a16f2920c02244c10756bb2f1a11e87a22>
[12] [CITE@en[Use backticks around header names and values · whatwg/html@9329c5a]]
([TIME[2015-09-19 13:07:56 +09:00]] 版)
<https://github.com/whatwg/html/commit/9329c5a77980d541bcc07ac9f5a2489ba42df729>
[13] [CITE@en[Replace byte stream with ReadableStream · whatwg/xhr@243bb82]]
([TIME[2016-03-23 17:33:56 +09:00]] 版)
<https://github.com/whatwg/xhr/commit/243bb82b5249e6405705b8eb252dd8bd416bd5f6>
[17] [CITE@en[Editorial: refactor to depend on the Infra Standard]]
([[domenic]]著, [TIME[2016-11-17 07:29:00 +09:00]])
<https://github.com/whatwg/html/commit/4ac633e08c2c9430853fc8322943bc2438ed36a3>
[18] [CITE@en[Editorial: start using the Infra Standard]]
([[annevk]]著, [TIME[2016-11-18 23:44:14 +09:00]])
<https://github.com/whatwg/fetch/commit/9ba4e78e5cb5fc1132f89d7e344cd2c2e1950c67>
[19] [CITE@en[Limit the bytes you can express as string more]]
([[annevk]]著, [TIME[2017-03-17 20:40:17 +09:00]])
<https://github.com/whatwg/infra/commit/b99c4cd6bb8dd958ff66854aceda459baee41636>
[20] [CITE@en[Note how to get a byte sequence out of a string]]
([[annevk]]著, [TIME[2017-03-17 20:15:38 +09:00]])
<https://github.com/whatwg/infra/commit/8ca1cf3f500b030507e884742277e98f4482536c>
[21] [CITE@en[Define length for byte sequences and strings]]
([[annevk]]著, [TIME[2017-03-27 16:59:15 +09:00]])
<https://github.com/whatwg/infra/commit/c484a4fe0d7bdc52b0f17ab99e49eaa9e56e3f56>
[22] [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>