/
507.txt
890 lines (683 loc) · 20.6 KB
/
507.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
[SEE[ [[ISO/IEC 2022]] ]]
* ISO/IEC 2022 Decoder
[1] A [DFN[state]] is:
[FIG(list members)[
: [F[C0 designated]] : [[C0 set]].
Initially, the [[initial C0 set]].
: [F[2/0 designated]] : [CODE(charname)@en[SP]] or [CODE(charname)@en[MSP]].
Initially, [CODE(charname)@en[SP]].
: [F[7/15 designated]] : [CODE(charname)@en[DEL]].
: [F[C1 designated]] : [[C1 set]].
Initially. the [[empty C1 set]].
: [F[10/0 designated]] : [CODE(charname)@en[MSP]] or ([I[unassigned]], [[10/0]]).
Initially, ([I[unassigned]], [[10/0]]).
: [F[15/15 designated]] : ([I[unassigned]], [[15/15]]).
: [F[G0 designated]] : [[G set]].
Initially, the [[empty 94 set]].
: [F[G1 designated]] : [[G set]].
Initially, the [[empty 94 set]].
: [F[G2 designated]] : [[G set]].
Initially, the [[empty 94 set]].
: [F[G3 designated]] : [[G set]].
Initially, the [[empty 94 set]].
: [DFN[[F[bits]]]] : [I[8-bit]] or [I[7-bit]].
Initially, [I[8-bit]].
: [DFN[[F[MARC-8 flag]]]] : [[Boolean][boolean]].
Initially, [[false]].
: [DFN[[F[GL invoked]]]] : [[G element]] or [CODE[null]].
Initially, [CODE[null]].
: [DFN[[F[GR invoked]]]] : [[G element]] or [CODE[null]].
Initially, [CODE[null]].
: [DFN[[F[current sequence]]]] : [[Character string][character string]].
: [DFN[[F[PCD PM]]]] : [[Byte][byte]].
: [DFN[[F[PCD PI]]]] : [[Byte][byte]].
: [DFN[[F[PCD LI]]]] : Non-negative integer.
: [DFN[[F[PCD data]]]] : [[Byte sequence][byte sequence]].
: [DFN[[F[decoder state]]]] : One of [[decoder states][decoder state]].
Initially, [[initial state]].
]FIG]
[100] A [DFN[G element]] is [I[G0]], [I[G1]], [I[G2]], or [I[G3]].
[117] A [DFN[maximum sequence length]] is an implementation-specific integer,
e.g. [N[15]].
[94] A [DFN[maximum chunk length]] is an implementation-specific integer,
e.g. 2[SUP[30]] - 1.
[20] A [[state initialization steps]] is a set of zero or more steps
that modifies [VAR[state]]. It [MAY[MAY]] modify [VAR[state]] in these ways:
- [21] Modify values of [VAR[state]]'s
[F[C0 designated]],
[F[2/0 designated]],
[F[7/15 designated]],
[F[C1 designated]],
[F[10/0 designated]],
[F[15/15 designated]],
[F[G0 designated]],
[F[G1 designated]],
[F[G2 designated]],
[F[G3 designated]],
[F[bits]],
and/or
[F[MARC-8 flag]].
[4]
To [DFN[emit a character]] with [[character]] [VAR[char]], run these steps:
[FIG(steps)[
=
[5]
[[Append][append]]
[VAR[char]]
to
[VAR[output stream]].
]FIG]
[115]
To [DFN[emit a sequence]] with [[character string]] [VAR[seq]], run these steps:
[FIG(steps)[
=
[116]
[[Extend][extend]]
[VAR[output stream]]
with
[VAR[seq]].
]FIG]
[95]
To [DFN[emit a PCD data]] with [[byte]] [VAR[PM]], [[byte]] [VAR[PI]],
[[byte sequence]] [VAR[data]], run these steps:
[FIG(steps)[
=
[96]
[[Append][append]]
a new [[PCD data]]
to
[VAR[output stream]]:
[FIG(list members)[
:[F[picture mode]]: [VAR[PM]]
:[F[picture identifier]]: [VAR[PI]]
:[F[picture data entity]]: [VAR[data]]
]FIG]
]FIG]
[58]
When [DFN[deprecated]], run these steps:
[FIG(steps)[
= [59]
Usage of an undesired feature [MAY[may]] be reported to a [[developer console]].
]FIG]
@@
[VAR[input stream]],
[VAR[initialization steps]] a [[state initialization steps]],
run these steps:
[FIG(steps)[
= [8] Let [VAR[state]] be a new [[state]].
= [9] Run [VAR[initialization steps]] with [VAR[state]].
= [6]
Let [VAR[output stream]] be a [[list]].
[NOTE[
[97] [VAR[output stream]] might contain
[[characters][character]],
[[PCD data]],
and
[[EOF]].
]NOTE]
= [10]
@@
Process the input stream,
a sequence of zero or more [[bit combinations][bit combination]]
= [7]
Return [VAR[output stream]].
]FIG]
@@[DFN[reconsume]]
@@
** Decoder states
[2] There are the following [DFN[decoder states][decoder state]]:
*** Initial state
[3] The [DFN[initial state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [N[0/0]], [N[1/15]] ] :
[FIG(steps)[
= [11] Let [VAR[set]] be [VAR[state]]'s [F[C0 designated]].
= [12] Let [VAR[char]] be [VAR[set]] [ [VAR[bc]] ].
= [29] If [VAR[char]] is [CODE(charname)@en[ESC]]:
== [30]
Set [VAR[state]]'s [F[decoder state]] to [[escape state]].
= [31] Otherwise:
== [13] [[Emit a character][emit a character]] [VAR[char]].
]FIG]
: [N[2/0]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[2/0 designated]].
: [N[7/15]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[7/15 designated]].
: [ [N[8/0]], [N[9/15]] ] :
[FIG(steps)[
= [26] Let [VAR[set]] be [VAR[state]]'s [F[C1 designated]].
= [27] Let [VAR[char]] be [VAR[set]] [ [VAR[bc]] ].
= [28] [[Emit a character][emit a character]] [VAR[char]].
]FIG]
: [N[10/0]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[10/0 designated]].
: [N[15/15]] :
[[Emit a character][emit a character]] [VAR[state]]'s [F[15/15 designated]].
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** Escape state
[32] The [DFN[escape state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [[2/0]] :
[FIG(steps)[
= [136] Set [VAR[state]]'s [F[decoder state]] to [I[escape 0 state]].
]FIG]
: [[2/1]] :
[FIG(steps)[
= [157] Set [VAR[state]]'s [F[decoder state]] to [I[escape 1 state]].
]FIG]
: [[2/2]] :
[FIG(steps)[
= [158] Set [VAR[state]]'s [F[decoder state]] to [I[escape 2 state]].
]FIG]
:[ [[2/3]], [[2/15]] ]:
[FIG(steps)[
@@
]FIG]
: [[2/3]] :
[FIG(steps)[
= [105] Set [VAR[state]]'s [F[current sequence]] to an [[empty character string]].
= [111] [[Append][append]]
a [[character]] ([I[sequence]], [VAR[bc]])
to [VAR[state]]'s [F[current sequence]].
= [104] Set [VAR[state]]'s [F[decoder state]] to [I[unassigned escape state]].
]FIG]
:[ [[4/0]], [[5/15]] ]:
[FIG(steps)[
= [36] Let [VAR[set]] be [VAR[state]]'s [F[C1 designated]].
= [37] Let [VAR[char]] be [VAR[set]] [ [VAR[bc]] + 0x40 ].
= [38] [[Emit a character][emit a character]] [VAR[char]].
= [39] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
]FIG]
:[ [[3/0]], [[3/15]] ], [[6/0]], [[6/1]], [[6/3]], [ [[6/5]], [[6/9]] ], [ [[7/1]], [[7/11]] ]:
[FIG(steps)[
= [35] [[Emit a character][emit a character]]
([VAR[escape]], [VAR[bc]]).
= [40] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
]FIG]
: [[6/2]] :
[FIG(steps)[
= [41] If [VAR[state]]'s [F[MARC-8 flag]] is [[true]]:
== [49]
Set [VAR[state]]'s [F[G0 designated]] to [[94 set]] ([I[escape]], [VAR[bc]]).
= [42] Otherwise:
== [43] [[Emit a character][emit a character]]
([VAR[escape]], [VAR[bc]]).
= [44] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
]FIG]
: [[6/4]] :
[FIG(steps)[
= [48] Set [VAR[state]]'s [F[decoder state]] to [I[foreign state]].
]FIG]
: [[6/11]] :
[FIG(steps)[
= [55] [[Deprecated][deprecated]].
= [118] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [119] Set [VAR[state]]'s [F[GL invoked]] to [I[G1]].
= [120] Otherwise:
== [52] Set [VAR[state]]'s [F[GR invoked]] to [I[G1]].
]FIG]
: [[6/12]] :
[FIG(steps)[
= [56] [[Deprecated][deprecated]].
= [121] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [122] Set [VAR[state]]'s [F[GL invoked]] to [I[G2]].
= [123] Otherwise:
== [53] Set [VAR[state]]'s [F[GR invoked]] to [I[G2]].
]FIG]
: [[6/13]] :
[FIG(steps)[
= [57] [[Deprecated][deprecated]].
= [124] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [125] Set [VAR[state]]'s [F[GL invoked]] to [I[G3]].
= [126] Otherwise:
== [54] Set [VAR[state]]'s [F[GR invoked]] to [I[G3]].
]FIG]
: [[6/14]] :
[FIG(steps)[
= [60] Set [VAR[state]]'s [F[GL invoked]] to [I[G2]].
]FIG]
: [[6/15]] :
[FIG(steps)[
= [61] Set [VAR[state]]'s [F[GL invoked]] to [I[G3]].
]FIG]
: [[7/0]] :
[FIG(steps)[
= [62] If [VAR[state]]'s [F[MARC-8 flag]] is [[true]]:
== [63]
Set [VAR[state]]'s [F[G0 designated]] to [[94 set]] ([I[escape]], [VAR[bc]]).
== [66] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
= [64] Otherwise:
== [65] Set [VAR[state]]'s [F[decoder state]] to [I[PCD state]].
]FIG]
: [[7/12]] :
[FIG(steps)[
= [127] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [128] Set [VAR[state]]'s [F[GL invoked]] to [I[G3]].
= [129] Otherwise:
== [101] Set [VAR[state]]'s [F[GR invoked]] to [I[G3]].
]FIG]
: [[7/13]] :
[FIG(steps)[
= [130] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [131] Set [VAR[state]]'s [F[GL invoked]] to [I[G2]].
= [132] Otherwise:
== [102] Set [VAR[state]]'s [F[GR invoked]] to [I[G2]].
]FIG]
: [[7/14]] :
[FIG(steps)[
= [133] If [VAR[state]]'s [F[bits]] is [I[7-bit]]:
== [134] Set [VAR[state]]'s [F[GL invoked]] to [I[G1]].
= [135] Otherwise:
== [103] Set [VAR[state]]'s [F[GR invoked]] to [I[G1]].
]FIG]
: Otherwise :
[FIG(steps)[
= [33] Set [VAR[state]]'s [F[current sequence]] be an [[empty character string]].
= [34] Set [VAR[state]]'s [F[decoder state]] to [I[unassigned escape state]].
= [156] [[Reconsume][reconsume]] [VAR[bc]].
]FIG]
]FIG]
*** Escape 0 state
[137] The [DFN[escape 0 state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [[4/1]], [[7/14]] ] :
[FIG(steps)[
= [138] Let [VAR[announce]] be [VAR[bc]] - 0x40.
= [139] If [VAR[announce]] is one of:
[N[1]],
[N[3]],
[N[12]],
[N[13]],
or
[N[14]]:
== [140] Set [VAR[state]]'s [F[GL invoked]] be [I[G0]].
= [141] If [VAR[announce]] is [N[1]] or [N[2]]:
== [142] Set [VAR[state]]'s [F[GR invoked]] be [CODE[null]].
= [143] If [VAR[announce]] is one of:
[N[3]],
[N[12]],
[N[13]],
or
[N[14]]:
== [144] Set [VAR[state]]'s [F[GR invoked]] be [I[G1]].
= [145] If [VAR[announce]] is one of:
[N[12]],
[N[13]],
or
[N[14]]:
== [146] Set [VAR[state]]'s [F[2/0 designated]] be [CODE(charname)@en[SP]].
== [147] Set [VAR[state]]'s [F[7/14 designated]] be [CODE(charname)@en[DEL]].
= [148] If [VAR[announce]] is one of:
[N[11]],
[N[12]],
[N[13]],
or
[N[14]]:
== [149] Set [VAR[state]]'s [F[bits]] be [I[8-bit]].
= [150] If [VAR[announce]] is [N[10]]:
== [151] Set [VAR[state]]'s [F[bits]] be [I[7-bit]].
]FIG]
: Otherwise :
[FIG(steps)[
= [152] Set [VAR[state]]'s [F[current sequence]] be an [[empty character string]].
= [153] [[Append][append]]
a [[character]] ([I[sequence]], [[2/0]])
to [VAR[state]]'s [F[current sequence]].
= [155] Set [VAR[state]]'s [F[decoder state]] to [I[unassigned escape state]].
= [154] [[Reconsume][reconsume]] [VAR[bc]].
]FIG]
]FIG]
*** Escape 1 state
[159] The [DFN[escape 1 state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [[3/0]], [[7/14]] ] :
[FIG(steps)[
= [164] Let [VAR[state]]'s [F[C0 designated]] be [[control set]] ([I[C0]], [VAR[bc]]).
]FIG]
: Otherwise :
[FIG(steps)[
= [160] Set [VAR[state]]'s [F[current sequence]] be an [[empty character string]].
= [161] [[Append][append]]
a [[character]] ([I[sequence]], [[2/1]])
to [VAR[state]]'s [F[current sequence]].
= [162] Set [VAR[state]]'s [F[decoder state]] to [I[unassigned escape state]].
= [163] [[Reconsume][reconsume]] [VAR[bc]].
]FIG]
]FIG]
*** Escape 2 state
[165] The [DFN[escape 2 state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [[3/0]], [[7/14]] ] :
[FIG(steps)[
= [166] Let [VAR[state]]'s [F[C1 designated]] be [[control set]] ([I[C1]], [VAR[bc]]).
]FIG]
: Otherwise :
[FIG(steps)[
= [167] Set [VAR[state]]'s [F[current sequence]] be an [[empty character string]].
= [168] [[Append][append]]
a [[character]] ([I[sequence]], [[2/2]])
to [VAR[state]]'s [F[current sequence]].
= [169] Set [VAR[state]]'s [F[decoder state]] to [I[unassigned escape state]].
= [170] [[Reconsume][reconsume]] [VAR[bc]].
]FIG]
]FIG]
*** Unassigned escape state
[106] The [DFN[unassigned escape state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [[2/0]], [[2/15]] ] :
[FIG(steps)[
= [107] [[Append][append]]
a [[character]] ([I[sequence]], [VAR[bc]])
to [VAR[state]]'s [F[current sequence]].
= [110] If [VAR[state]]'s [F[current sequence]]'s [[length]]
is equal to the [[maximum sequence length]]:
==
@@
]FIG]
: [ [[3/0]], [[7/14]] ] :
[FIG(steps)[
= [108] [[Append][append to a byte sequence]]
a [[character]] ([I[sequence]], [VAR[bc]])
to [VAR[state]]'s [F[current sequence]].
= [114] [[Emit a sequence][emit a sequence]]
[VAR[state]]'s [F[current sequence]].
= [109] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** PCD state
[67] The [DFN[PCD state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [N[0/0]], [N[15/15]] ] :
[FIG(steps)[
= [68] Set [VAR[state]]'s [F[PCD PM]] to [VAR[bc]].
= [69] Set [VAR[state]]'s [F[decoder state]] to [I[PCD PM state]].
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** PCD PM state
[70] The [DFN[PCD PM state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
: [ [N[0/0]], [N[15/15]] ] :
[FIG(steps)[
= [71] Set [VAR[state]]'s [F[PCD PI]] to [VAR[bc]].
= [73] Set [VAR[state]]'s [F[PCD LI]] to [N[0]].
= [72] Set [VAR[state]]'s [F[decoder state]] to [I[PCD PI state]].
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** PCD PI state
[74] The [DFN[PCD PI state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
:[ [[10/0]], [[11/1]] ]:
[FIG(steps)[
= [75] Set [VAR[state]]'s [F[PCD LI]] to ([VAR[state]]'s [F[PCD LI]] << 5) + ([VAR[bc]] & [N[0b11111]]).
= [77] If [VAR[state]]'s [F[PCD LI]] is greater than the
[[maximum chunk length]]:
==
@@
]FIG]
:[ [[8/13]], [[9/14]] ]:
[FIG(steps)[
= [78] Set [VAR[state]]'s [F[PCD LI]] to
([VAR[state]]'s [F[PCD LI]] << 5) + ([VAR[bc]] & [N[0b11111]]).
= [79] If [VAR[state]]'s [F[PCD LI]] is greater than the
[[maximum chunk length]]:
==
@@
= [87] Set [VAR[state]]'s [F[PCD data]] to the [[empty byte sequence]].
= [82] If [VAR[state]]'s [F[PCD LI]] is zero:
== [93] [[Emit a PCD data][emit a PCD data]]
[VAR[state]]'s [F[PCD PM]],
[VAR[state]]'s [F[PCD PI]],
[VAR[state]]'s [F[PCD data]].
== [83] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
= [84] Otherwise:
== [80] Set [VAR[state]]'s [F[decoder state]] to [I[PCD LI state]].
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** PCD LI state
[81] The [DFN[PCD LI state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
:[ [[0/0]], [[15/15]] ]:
[FIG(steps)[
= [88] [[Append][append to a byte sequence]] [VAR[bc]] to [VAR[state]]'s [F[PCD data]].
= [76] Set [VAR[state]]'s [F[PCD LI]] to [VAR[state]]'s [F[PCD LI]] - 1.
= [85] If [VAR[state]]'s [F[PCD LI]] is zero:
== [92] [[Emit a PCD data][emit a PCD data]]
[VAR[state]]'s [F[PCD PM]],
[VAR[state]]'s [F[PCD PI]],
[VAR[state]]'s [F[PCD data]].
== [86] Set [VAR[state]]'s [F[decoder state]] to [I[initial state]].
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
*** Foreign state
[50] The [DFN[foreign state]] switches by the [[bit combination]] [VAR[bc]]:
[FIG(switch)[
:[ [[0/0]], [[15/15]] ]:
[FIG(steps)[
= [51] [[Emit a character][emit a character]]
([VAR[unassigned]], [VAR[bc]]).
]FIG]
: [[EOF]] :
@@
: Otherwise :
@@
]FIG]
* Character sets
[17]
A [DFN[character set]] is an [[ordered map]],
where [[keys][key]] are [[byte sequences][byte sequence]] and
[[values][value]] are a [[character]].
[171]
To [DFN[get a character set]] with
[[byte]] [VAR[start]],
[[byte]] [VAR[end]],
[VAR[t1]],
and
[VAR[t2]],
run these steps:
[FIG(steps)[
= [172] Let [VAR[set]] be a new [[character set]].
= [173] [[For each]] [VAR[c]] in [ [VAR[start]], [VAR[end]] ]:
== [174] Let [VAR[set]] [ [VAR[c]] ] be
a [[character]] ([VAR[t1]], [VAR[t2]], [VAR[c]]).
= [175] Return [VAR[set]].
]FIG]
[22]
A [DFN[C0 set]] is a [[character set]] whose [[keys][key]] are
«
[[0/0]],
[[0/1]],
...,
[[1/15]]
».
[176]
To [[get a C0 set]] [VAR[F]], run these steps:
[FIG(steps)[
= [177] Let [VAR[set]] be the result of running the steps to
[[get a character set]]
with [[0/0]], [[1/15]], [I[C0]], and [VAR[F]].
= [180] If [VAR[F]] is ''not'' [[7/14]]:
== [178] Set [VAR[set]] [ [[1/11]] ] to [CODE(charname)@en[ESC]].
= [187] If [VAR[F]] is one of:
[[4/1]] ([[ISO-IR]] 1),
[[4/3]] ([[ISO-IR]] 26),
[[4/4]] ([[ISO-IR]] 36),
[[4/6]] ([[ISO-IR]] 74),
[[4/11]] ([[ISO-IR]] 135),
[[4/12]] ([[ISO-IR]] 140),
[[4/5]] ([[ISO-IR]] 106),
[[4/8]] ([[ISO-IR]] 130),
or
[[4/10]] ([[ISO-IR]] 134):
== [188] Set [VAR[set]] [ [[0/14]] ] to [CODE(charname)@en[LS1]].
== [189] Set [VAR[set]] [ [[0/15]] ] to [CODE(charname)@en[LS0]].
= [190] If [VAR[F]] is [[4/4]] ([[ISO-IR]] 36):
== [191] Set [VAR[set]] [ [[1/12]] ] to [CODE(charname)@en[SS2]].
= [192] If [VAR[F]] is one of:
[[4/5]] ([[ISO-IR]] 106),
[[4/9]] ([[ISO-IR]] 132),
[[4/10]] ([[ISO-IR]] 134),
or
[[4/12]] ([[ISO-IR]] 135):
== [193] Set [VAR[set]] [ [[1/9]] ] to [CODE(charname)@en[SS2]].
== [193] Set [VAR[set]] [ [[1/14]] ] to [CODE(charname)@en[SS3]].
= [194] If [VAR[F]] is [[4/12]] ([[ISO-IR]] 140):
== [195] Set [VAR[set]] [ [[1/9]] ] to [CODE(charname)@en[SS2]].
= [179] Return [VAR[set]].
]FIG]
[19]
The [DFN[initial C0 set]] is the result of running the steps to
[[get a C0 set]] [I[unassigned]].
[23]
A [DFN[C1 set]] is a [[character set]] whose [[keys][key]] are
«
[[8/0]],
[[0/1]],
...,
[[9/15]]
».
[25]
To [[get a C1 set]] [VAR[F]], run these steps:
[FIG(steps)[
= [181] Let [VAR[set]] be the result of running the steps to
[[get a character set]]
with [[8/0]], [[9/15]], [I[C1]], and [VAR[F]].
= [182] Return [VAR[set]].
]FIG]
[24]
The [DFN[empty C1 set]] is the result of running the steps to
[[get a C1 set]] [[7/14]].
@@
[45]
A [DFN[G set]] is ...
[46]
To [[get a 94 set]] [VAR[F]], run these steps:
[FIG(steps)[
= [183] Let [VAR[set]] be the result of running the steps to
[[get a character set]]
with [[2/1]], [[7/14]], [I[94]], and [VAR[F]].
= [184] Return [VAR[set]].
]FIG]
[185]
The [DFN[empty 94 set]] is the result of running the steps to
[[get a 94 set]] [[7/14]].
[47] [DFN[94 set]] ([VAR[c1]], [VAR[c2]]) is defined by the following table:
[FIG(table)[
:c1:[VAR[c1]]
:c2:[VAR[c2]]
:set:[[94 set]] ([VAR[c1]], [VAR[c2]])
:note:[[Note]] ([[non-normative]])
:c1:[I[escape]]
:c2: [[6/2]]
:note: [[MARC-8]]
:set:
@@
:c1:[I[escape]]
:c2: [[6/7]]
:note: [[MARC-8]]
:set:
@@
:c1:[I[escape]]
:c2: [[7/0]]
:note: [[MARC-8]]
:set:
@@
:c1:[I[escape]]
:c2: [[7/3]]
:note: [[MARC-8]]
:set:
@@ASCII
]FIG]
* Definitions
[14]
This document depends on the [CITE[Infra Standard]].
[15]
The terms
[[for each][For each]],
[[boolean]],
[[byte]],
[[byte sequence]],
[[length]],
[[tuple]],
[[list]],
[[append]],
[[extend]],
[[ordered map]],
[[entry]],
[[key]],
and
[[value]]
are defined by the [CITE[Infra Standard]].
[16]
A [DFN[bit combination]] is a [[byte]].
A [[bit combination]] is represented as "[VAR[X]]/[VAR[Y]]",
where [VAR[X]] and [VAR[Y]] are integers in [ [N[0]], [N[15]] ],
which represents a [[byte]] [VAR[X]] × [N[16]] + [VAR[Y]].
[89]
To [DFN[append][append to a byte sequence]] a [[bit combination]] [VAR[bc]]
to a [[byte sequence]] [VAR[bytes]], run these steps:
[FIG(steps)[
= [90] Replace [VAR[bytes]]'s content by [VAR[bytes]] followed by [VAR[bc]].
]FIG]
[91] The [DFN[empty byte sequence]] is a [[byte sequence]] whose [[length]]
is [N[0]].
[18]
A [DFN[character]] is one of followings:
- [CODE(charname)@en[ESC]]
- [CODE(charname)@en[SP]]
- [CODE(charname)@en[MSP]]
- [CODE(charname)@en[DEL]]
- [[tuple]] ([I[escape]], [VAR[bc]]), where [VAR[bc]] is a [[bit combination]]
- [[tuple]] ([I[sequence]], [VAR[bc]]), where [VAR[bc]] is a [[bit combination]]
- [[tuple]] ([I[unassigned]], [VAR[bc]]), where [VAR[bc]] is a [[bit combination]]
- [[tuple]] ([I[C0]], [VAR[F]], [VAR[bc]]),
where [VAR[bc]] and [VAR[F]] are [[bit combinations][bit combination]]
- [[tuple]] ([I[C1]], [VAR[F]], [VAR[bc]]),
where [VAR[bc]] and [VAR[F]] are [[bit combinations][bit combination]]
- [[tuple]] ([I[94]], [VAR[F]], [VAR[bc]]),
where [VAR[bc]] and [VAR[F]] are [[bit combinations][bit combination]]
- [[tuple]] ([I[96]], [VAR[F]], [VAR[bc]]),
where [VAR[bc]] and [VAR[F]] are [[bit combinations][bit combination]]
;; [186]
Interpretation of these [[tuples][tuple]] are application-specific.
[112]
A [DFN[character string]] is a [[list]] of zero or more [[characters][character]].
[113]
An [DFN[empty character string]] is a [[character string]] whose [[length]]
is [N[0]].
[98]
A [DFN[PCD data]]
is a [[tuple]] consisting of:
[DFN[[F[picture mode]]]] ([[byte]]),
[DFN[[F[picture identifier]]]] ([[byte]]),
and
[DFN[[F[picture data]]]] ([[byte sequence]]).
@@
[99]
[DFN[EOF]]
* Notes
@@macro code,
[[SCI]]