diff --git a/encoding.bs b/encoding.bs index 6e591d7..6bfcb55 100644 --- a/encoding.bs +++ b/encoding.bs @@ -46,8 +46,8 @@ specification does not provide a mechanism for extending any aspect of encodings encoding in use, or on the way a given encoding is to be implemented. For instance, an attack was reported in 2011 where a Shift_JIS lead byte 0x82 was used to “mask” a 0x22 trail byte in a JSON resource of which an attacker could control some field. The producer did not see the problem -even though this is an illegal byte combination. The consumer decoded it as a single U+FFFD and -therefore changed the overall interpretation as U+0022 is an important delimiter. Decoders of +even though this is an illegal byte combination. The consumer decoded it as a single U+FFFD (�) and +therefore changed the overall interpretation as U+0022 (") is an important delimiter. Decoders of encodings that use multiple bytes for scalar values now require that in case of an illegal byte combination, a scalar value in the range U+0000 to U+007F, inclusive, cannot be “masked”. For the aforementioned sequence the output would be U+FFFD U+0022. (As an unfortunate exception to this, the @@ -179,7 +179,7 @@ from an I/O queue ioQueue, run these steps:
  1. -

    If the last item in ioQueue is end-of-queue, then: +

    If the last item in ioQueue is end-of-queue:

    1. If item is end-of-queue, do nothing. @@ -786,9 +786,9 @@ duplicated. decoder and one for its encoder.

      To find the pointers and their corresponding code points in an index, -let lines be the result of splitting the resource's contents on U+000A. -Then remove each item in lines that is the empty string or starts with U+0023. -Then the pointers and their corresponding code points are found by splitting each item in lines on U+0009. +let lines be the result of splitting the resource's contents on U+000A LF. +Then remove each item in lines that is the empty string or starts with U+0023 (#). +Then the pointers and their corresponding code points are found by splitting each item in lines on U+0009 TAB. The first subitem is the pointer (as a decimal number) and the second is the corresponding code point (as a hexadecimal number). Other subitems are not relevant. @@ -801,10 +801,10 @@ changed, so has the index. pointer in index, or null if pointer is not in index. -

      The index pointer for code point in +

      The index pointer for codePoint in index is the first pointer corresponding to -code point in index, or null if -code point is not in index. +codePoint in index, or null if +codePoint is not in index.

      There is a non-normative visualization for each index other than @@ -918,10 +918,10 @@ specification, excluding index single-byte, which have their own table: the return value of these steps:

        -
      1. If pointer is greater than 39419 and less than - 189000, or pointer is greater than 1237575, return null. +

      2. If pointer is greater than 39419 and less than 189000, or pointer is + greater than 1237575, then return null. -

      3. If pointer is 7457, return code point U+E7C7. +

      4. If pointer is 7457, then return code point U+E7C7.

      5. Let offset be the last pointer in index gb18030 ranges that is less than @@ -934,23 +934,23 @@ the return value of these steps:

      -

      The index gb18030 ranges pointer for code point is +

      The index gb18030 ranges pointer for codePoint is the return value of these steps:

        -
      1. If code point is U+E7C7, return pointer 7457. +

      2. If codePoint is U+E7C7, then return pointer 7457.

      3. Let offset be the last code point in index gb18030 ranges that is less - than or equal to code point and let pointer offset be its corresponding + than or equal to codePoint and let pointer offset be its corresponding pointer.

      4. Return a pointer whose value is - pointer offset + code pointoffset. + pointer offset + codePointoffset.

      -

      The index Shift_JIS pointer for code point is the return value of these +

      The index Shift_JIS pointer for codePoint is the return value of these steps:

        @@ -963,13 +963,12 @@ steps:

        The index jis0208 contains duplicate code points so the exclusion of these entries causes later code points to be used. -

      1. Return the index pointer for code point in - index. +

      2. Return the index pointer for codePoint in index.

      -

      The index Big5 pointer for code point is the return value of +

      The index Big5 pointer for codePoint is the return value of these steps:

        @@ -980,16 +979,15 @@ these steps:

        Avoid returning Hong Kong Supplementary Character Set extensions literally.

      1. -

        If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or U+5345, - return the last pointer corresponding to code point in +

        If codePoint is U+2550, U+255E, U+2561, U+256A, U+5341, or U+5345, + return the last pointer corresponding to codePoint in index.

        There are other duplicate code points, but for those the first pointer is to be used. -

      2. Return the index pointer for code point in - index. +

      3. Return the index pointer for codePoint in index.

      @@ -1352,12 +1350,12 @@ interface mixin TextDecoderCommon {
    2. If decoder's encoding is UTF-8 or UTF-16BE/LE, and decoder's ignore BOM and - BOM seen are false, then: + BOM seen are false:

      1. Set decoder's BOM seen to true. -

      2. If item is U+FEFF, then continue. +

      3. If item is U+FEFF BOM, then continue.

    3. Append item to output. @@ -1380,7 +1378,7 @@ getter steps are to return this's encoding's

      The fatal getter steps are to return true if this's error mode is -"fatal", otherwise false. +"fatal"; otherwise false.

      @@ -1426,7 +1424,7 @@ initially false.

      Returns encoding's name, lowercased.

      decoder . fatal -

      Returns true if error mode is "fatal", otherwise +

      Returns true if error mode is "fatal"; otherwise false.

      decoder . ignoreBOM @@ -1674,7 +1672,7 @@ method steps are:
      1. If destination's byte length − - written is greater than or equal to the number of bytes in result, then: + written is greater than or equal to the number of bytes in result:

        1. If item is greater than U+FFFF, then increment read by 2. @@ -1856,7 +1854,7 @@ constructor steps are: I/O queue.

        2. -

          If item is end-of-queue, then: +

          If item is end-of-queue:

          1. Let outputChunk be the result of running serialize I/O queue with @@ -1900,7 +1898,7 @@ steps: error mode.

          2. -

            If result is finished, then: +

            If result is finished:

            1. Let outputChunk be the result of running serialize I/O queue with @@ -2014,7 +2012,7 @@ constructor steps are:

              {{DOMString}}, as well as an I/O queue of code units rather than scalar values, are used here so that a surrogate pair that is split between chunks can be reassembled into the appropriate scalar value. The behavior is otherwise identical to {{USVString}}. In particular, - lone surrogates will be replaced with U+FFFD. + lone surrogates will be replaced with U+FFFD (�).

            2. Let output be the I/O queue of bytes « end-of-queue ». @@ -2025,13 +2023,13 @@ constructor steps are:

            3. Let item be the result of reading from input.

            4. -

              If item is end-of-queue, then: +

              If item is end-of-queue:

              1. Convert output into a byte sequence.

              2. -

                If output is non-empty, then: +

                If output is non-empty:

                1. Let chunk be a {{Uint8Array}} object wrapping an {{ArrayBuffer}} containing @@ -2061,7 +2059,7 @@ constructor steps are:

                  1. -

                    If encoder's leading surrogate is non-null, then: +

                    If encoder's leading surrogate is non-null:

                    1. Let leadingSurrogate be encoder's @@ -2074,13 +2072,13 @@ constructor steps are:

                    2. Restore item to input. -

                    3. Return U+FFFD. +

                    4. Return U+FFFD (�).

                  2. If item is a leading surrogate, then set encoder's leading surrogate to item and return continue. -

                  3. If item is a trailing surrogate, then return U+FFFD. +

                  4. If item is a trailing surrogate, then return U+FFFD (�).

                  5. Return item.

                  @@ -2096,7 +2094,7 @@ that are split between strings. [[!INFRA]]
                  1. -

                    If encoder's leading surrogate is non-null, then: +

                    If encoder's leading surrogate is non-null:

                    1. @@ -2136,8 +2134,7 @@ in deployed content. Therefore it is not part of the UTF-8 decoder algori UTF-8 bytes needed is not 0, set UTF-8 bytes needed to 0 and return error. -
                    2. If byte is end-of-queue, return - finished. +

                    3. If byte is end-of-queue, then return finished.

                    4. If UTF-8 bytes needed is 0, based on byte: @@ -2199,7 +2196,7 @@ in deployed content. Therefore it is not part of the UTF-8 decoder algori

                    5. If byte is not in the range UTF-8 lower boundary to - UTF-8 upper boundary, inclusive, then: + UTF-8 upper boundary, inclusive:

                      1. Set UTF-8 code point, @@ -2225,15 +2222,15 @@ in deployed content. Therefore it is not part of the UTF-8 decoder algori

                      2. Increase UTF-8 bytes seen by one. -

                      3. If UTF-8 bytes seen is not equal to - UTF-8 bytes needed, return continue. +

                      4. If UTF-8 bytes seen is not equal to UTF-8 bytes needed, then return + continue. -

                      5. Let code point be UTF-8 code point. +

                      6. Let codePoint be UTF-8 code point.

                      7. Set UTF-8 code point, UTF-8 bytes needed, and UTF-8 bytes seen to 0. -

                      8. Return a code point whose value is code point. +

                      9. Return a code point whose value is codePoint.

                      The constraints in the UTF-8 decoder above match @@ -2246,18 +2243,17 @@ achieve the same result are fine, even encouraged).

                      UTF-8 encoder

                      UTF-8's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                        -
                      1. If code point is end-of-queue, return - finished. +

                      2. If codePoint is end-of-queue, then return finished. -

                      3. If code point is an ASCII code point, return - a byte whose value is code point. +

                      4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint.

                      5. Set count and offset based on the - range code point is in: + range codePoint is in:

                        U+0080 to U+07FF, inclusive @@ -2269,14 +2265,14 @@ achieve the same result are fine, even encouraged).
                      6. Let bytes be a byte sequence whose first byte is - (code point >> (6 × count)) + offset. + (codePoint >> (6 × count)) + offset.

                      7. While count is greater than 0:

                        1. Set temp to - code point >> (6 × (count − 1)). + codePoint >> (6 × (count − 1)).

                        2. Append to bytes 0x80 | (temp & 0x3F). @@ -2347,37 +2343,34 @@ historically this might have been the case for ISO-8859-6 and unused and byte, runs these steps:

                            -
                          1. If byte is end-of-queue, return - finished. +

                          2. If byte is end-of-queue, then return finished. -

                          3. If byte is an ASCII byte, return a code point whose value - is byte. +

                          4. If byte is an ASCII byte, then return a code point whose value is + byte. -

                          5. Let code point be the index code point +

                          6. Let codePoint be the index code point for byte − 0x80 in index single-byte. -

                          7. If code point is null, return error. +

                          8. If codePoint is null, then return error. -

                          9. Return a code point whose value is code point. +

                          10. Return a code point whose value is codePoint.

                          single-byte encoder

                          Single-byte encodings's encoder's handler, given -unused and code point, runs these steps: +unused and codePoint, runs these steps:

                            -
                          1. If code point is end-of-queue, return - finished. +

                          2. If codePoint is end-of-queue, then return finished. -

                          3. If code point is an ASCII code point, return - a byte whose value is code point. +

                          4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                          5. Let pointer be the index pointer for - code point in index single-byte. +

                          6. Let pointer be the index pointer for codePoint in + index single-byte. -

                          7. If pointer is null, return error with - code point. +

                          8. If pointer is null, then return error with codePoint.

                          9. Return a byte whose value is pointer + 0x80.

                          @@ -2414,21 +2407,19 @@ consumers of content generated with GBK's encoder. ioQueue and byte, runs these steps:
                            -
                          1. If byte is end-of-queue and - gb18030 first, gb18030 second, and gb18030 third - are 0x00, return finished. +

                          2. If byte is end-of-queue and gb18030 first, gb18030 second, + and gb18030 third are 0x00, then return finished. -

                          3. If byte is end-of-queue, and - gb18030 first, gb18030 second, or gb18030 third - is not 0x00, set gb18030 first, gb18030 second, and +

                          4. If byte is end-of-queue, and gb18030 first, gb18030 second, + or gb18030 third is not 0x00, then set gb18030 first, gb18030 second, and gb18030 third to 0x00, and return error.

                          5. -

                            If gb18030 third is not 0x00, then: +

                            If gb18030 third is not 0x00:

                            1. -

                              If byte is not in the range 0x30 to 0x39, inclusive, then: +

                              If byte is not in the range 0x30 to 0x39, inclusive:

                              1. Restore « gb18030 second, gb18030 third, byte » to @@ -2439,20 +2430,20 @@ consumers of content generated with GBK's encoder.

                              2. Return error.

                              -
                            2. Let code point be the index gb18030 ranges code point for +

                            3. Let codePoint be the index gb18030 ranges code point for ((gb18030 first − 0x81) × (10 × 126 × 10)) + ((gb18030 second − 0x30) × (10 × 126)) + ((gb18030 third − 0x81) × 10) + byte − 0x30.

                            4. Set gb18030 first, gb18030 second, and gb18030 third to 0x00. -

                            5. If code point is null, return error. +

                            6. If codePoint is null, then return error. -

                            7. Return a code point whose value is code point. +

                            8. Return a code point whose value is codePoint.

                          6. -

                            If gb18030 second is not 0x00, then: +

                            If gb18030 second is not 0x00:

                            1. If byte is in the range 0x81 to 0xFE, inclusive, set @@ -2463,7 +2454,7 @@ consumers of content generated with GBK's encoder.

                          7. -

                            If gb18030 first is not 0x00, then: +

                            If gb18030 first is not 0x00:

                            1. If byte is in the range 0x30 to 0x39, inclusive, set @@ -2472,31 +2463,31 @@ consumers of content generated with GBK's encoder.

                            2. Let lead be gb18030 first, let pointer be null, and set gb18030 first to 0x00. -

                            3. Let offset be 0x40 if byte is less than 0x7F, otherwise 0x41. +

                            4. Let offset be 0x40 if byte is less than 0x7F; otherwise 0x41.

                            5. If byte is in the range 0x40 to 0x7E, inclusive, or 0x80 to 0xFE, inclusive, set pointer to (lead − 0x81) × 190 + (byteoffset). -

                            6. Let code point be null if pointer is null, otherwise the +

                            7. Let codePoint be null if pointer is null; otherwise the index code point for pointer in index gb18030. -

                            8. If code point is non-null, return a code point whose value is - code point. +

                            9. If codePoint is non-null, then return a code point whose value is + codePoint. -

                            10. If byte is an ASCII byte, restore byte to +

                            11. If byte is an ASCII byte, then restore byte to ioQueue.

                            12. Return error.

                            -
                          8. If byte is an ASCII byte, return - a code point whose value is byte. +

                          9. If byte is an ASCII byte, then return a code point whose value is + byte. -

                          10. If byte is 0x80, return code point U+20AC. +

                          11. If byte is 0x80, then return code point U+20AC (€). -

                          12. If byte is in the range 0x81 to 0xFE, inclusive, set - gb18030 first to byte and return continue. +

                          13. If byte is in the range 0x81 to 0xFE, inclusive, then set gb18030 first to + byte and return continue.

                          14. Return error.

                          @@ -2508,26 +2499,24 @@ consumers of content generated with GBK's encoder. (initially false).

                          gb18030's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                            -
                          1. If code point is end-of-queue, return - finished. +

                          2. If codePoint is end-of-queue, then return finished. -

                          3. If code point is an ASCII code point, return - a byte whose value is code point. +

                          4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint.

                          5. -

                            If code point is U+E5E5, return error with code point. +

                            If codePoint is U+E5E5, then return error with codePoint.

                            Index gb18030 maps 0xA3 0xA0 to U+3000 rather than U+E5E5 for compatibility with deployed content. Therefore it cannot roundtrip. -

                          6. If is GBK is true and code point is - U+20AC, return byte 0x80. +

                          7. If is GBK is true and codePoint is U+20AC (€), then return byte 0x80.

                          8. -

                            If there is a row in the table below whose first column is code point, then return +

                            If there is a row in the table below whose first column is codePoint, then return the two bytes on the same row listed in the second column: @@ -2593,11 +2582,11 @@ consumers of content generated with GBK's encoder.

                            This asymmetric encoder table preserves compatibility with the GB18030-2005 standard. See also the explanation at index gb18030 ranges. -

                          9. Let pointer be the index pointer for - code point in index gb18030. +

                          10. Let pointer be the index pointer for codePoint in + index gb18030.

                          11. -

                            If pointer is non-null, then: +

                            If pointer is non-null:

                            1. Let lead be pointer / 190 + 0x81. @@ -2611,11 +2600,10 @@ consumers of content generated with GBK's encoder. trail + offset.

                            -
                          12. If is GBK is true, return error with - code point. +

                          13. If is GBK is true, then return error with codePoint.

                          14. Set pointer to the - index gb18030 ranges pointer for code point. + index gb18030 ranges pointer for codePoint.

                          15. Let byte1 be pointer / (10 × 126 × 10). @@ -2655,19 +2643,23 @@ consumers of content generated with GBK's encoder. and byte, runs these steps:

                              -
                            1. If byte is end-of-queue and Big5 lead - is not 0x00, set Big5 lead to 0x00 and return error. +

                            2. If byte is end-of-queue and Big5 lead is not 0x00, then set + Big5 lead to 0x00 and return error. -

                            3. If byte is end-of-queue and Big5 lead - is 0x00, return finished. +

                            4. If byte is end-of-queue and Big5 lead is 0x00, then return + finished.

                            5. -

                              If Big5 lead is not 0x00, let lead be - Big5 lead, let pointer be null, set - Big5 lead to 0x00, and then: +

                              If Big5 lead is not 0x00:

                                -
                              1. Let offset be 0x40 if byte is less than 0x7F, otherwise 0x62. +

                              2. Let lead be Big5 lead. + +

                              3. Set Big5 lead to 0x00. + +

                              4. Let pointer be null. + +

                              5. Let offset be 0x40 if byte is less than 0x7F; otherwise 0x62.

                              6. If byte is in the range 0x40 to 0x7E, inclusive, or @@ -2675,9 +2667,8 @@ and byte, runs these steps: (lead − 0x81) × 157 + (byteoffset).

                              7. -

                                If there is a row in the table below whose first column is - pointer, return the two code points listed in - its second column (the third column is irrelevant): +

                                If there is a row in the table below whose first column is pointer, then return + the two code points listed in its second column (the third column is irrelevant):

                          16. PointerCode pointsNotes @@ -2691,11 +2682,11 @@ and byte, runs these steps:

                            Since indexes are limited to single code points this table is used for these pointers. -

                          17. Let code point be null if pointer is null, otherwise the +

                          18. Let codePoint be null if pointer is null; otherwise the index code point for pointer in index Big5. -

                          19. If code point is non-null, return a code point whose value is - code point. +

                          20. If codePoint is non-null, then return a code point whose value is + codePoint.

                          21. If byte is an ASCII byte, restore byte to ioQueue. @@ -2703,10 +2694,10 @@ and byte, runs these steps:

                          22. Return error. -

                          23. If byte is an ASCII byte, return - a code point whose value is byte. +

                          24. If byte is an ASCII byte, then return a code point whose value is + byte. -

                          25. If byte is in the range 0x81 to 0xFE, inclusive, set +

                          26. If byte is in the range 0x81 to 0xFE, inclusive, then set Big5 lead to byte and return continue.

                          27. Return error. @@ -2716,20 +2707,17 @@ and byte, runs these steps:

                            Big5 encoder

                            Big5's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                              -
                            1. If code point is end-of-queue, return - finished. +

                            2. If codePoint is end-of-queue, then return finished. -

                            3. If code point is an ASCII code point, return - a byte whose value is code point. +

                            4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                            5. Let pointer be the index Big5 pointer for - code point. +

                            6. Let pointer be the index Big5 pointer for codePoint. -

                            7. If pointer is null, return error with - code point. +

                            8. If pointer is null, then return error with codePoint.

                            9. Let lead be pointer / 157 + 0x81. @@ -2759,12 +2747,11 @@ and byte, runs these steps: ioQueue and byte, runs these steps:

                                -
                              1. If byte is end-of-queue and - EUC-JP lead is not 0x00, set EUC-JP lead to 0x00, and return - error. +

                              2. If byte is end-of-queue and EUC-JP lead is not 0x00, then set + EUC-JP lead to 0x00 and return error. -

                              3. If byte is end-of-queue and - EUC-JP lead is 0x00, return finished. +

                              4. If byte is end-of-queue and EUC-JP lead is 0x00, then return + finished.

                              5. If EUC-JP lead is 0x8E and byte is in the range 0xA1 to 0xDF, inclusive, set EUC-JP lead to 0x00 and return @@ -2776,35 +2763,37 @@ and byte, runs these steps: EUC-JP lead to byte, and return continue.

                              6. -

                                If EUC-JP lead is not 0x00, let lead be EUC-JP lead, set - EUC-JP lead to 0x00, and then: +

                                If EUC-JP lead is not 0x00:

                                  -
                                1. Let code point be null. +

                                2. Let lead be EUC-JP lead. + +

                                3. Set EUC-JP lead to 0x00. + +

                                4. Let codePoint be null.

                                5. If lead and byte are both in the range 0xA1 to 0xFE, inclusive, then - set code point to the index code point for + set codePoint to the index code point for (lead − 0xA1) × 94 + byte − 0xA1 in index jis0208 if EUC-JP jis0212 is false and in index jis0212 otherwise.

                                6. Set EUC-JP jis0212 to false. -

                                7. If code point is non-null, return a code point whose value is - code point. +

                                8. If codePoint is non-null, then return a code point whose value is + codePoint. -

                                9. If byte is an ASCII byte, restore byte to +

                                10. If byte is an ASCII byte, then restore byte to ioQueue.

                                11. Return error.

                                -
                              7. If byte is an ASCII byte, return - a code point whose value is byte. +

                              8. If byte is an ASCII byte, then return a code point whose value is + byte. -

                              9. If byte is 0x8E, 0x8F, or in the range 0xA1 to - 0xFE, inclusive, set EUC-JP lead to byte and return - continue. +

                              10. If byte is 0x8E, 0x8F, or in the range 0xA1 to 0xFE, inclusive, then set + EUC-JP lead to byte and return continue.

                              11. Return error.

                              @@ -2813,40 +2802,37 @@ and byte, runs these steps:

                              EUC-JP encoder

                              EUC-JP's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                                -
                              1. If code point is end-of-queue, return - finished. +

                              2. If codePoint is end-of-queue, then return finished. -

                              3. If code point is an ASCII code point, return - a byte whose value is code point. +

                              4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                              5. If code point is U+00A5, return byte 0x5C. +

                              6. If codePoint is U+00A5 (¥), then return byte 0x5C. -

                              7. If code point is U+203E, return byte 0x7E. +

                              8. If codePoint is U+203E (‾), then return byte 0x7E. -

                              9. If code point is in the range U+FF61 to U+FF9F, inclusive, return - two bytes whose values are 0x8E and code point − 0xFF61 + 0xA1. +

                              10. If codePoint is in the range U+FF61 to U+FF9F, inclusive, then return two bytes + whose values are 0x8E and codePoint − 0xFF61 + 0xA1. -

                              11. If code point is U+2212, set it to U+FF0D. +

                              12. If codePoint is U+2212 (−), then set it to U+FF0D (-).

                              13. -

                                Let pointer be the index pointer for code point in +

                                Let pointer be the index pointer for codePoint in index jis0208.

                                If pointer is non-null, it is less than 8836 due to the nature of index jis0208 and the index pointer operation. -

                              14. If pointer is null, return error with - code point. +

                              15. If pointer is null, then return error with codePoint.

                              16. Let lead be pointer / 94 + 0xA1.

                              17. Let trail be pointer % 94 + 0xA1. -

                              18. Return two bytes whose values are lead and - trail. +

                              19. Return two bytes whose values are lead and trail.

                              @@ -2904,10 +2890,10 @@ and byte, runs these steps: continue.
                              0x5C -

                              Set ISO-2022-JP output to false and return code point U+00A5. +

                              Set ISO-2022-JP output to false and return code point U+00A5 (¥).

                              0x7E -

                              Set ISO-2022-JP output to false and return code point U+203E. +

                              Set ISO-2022-JP output to false and return code point U+203E (‾).

                              0x00 to 0x7F, excluding 0x0E, 0x0F, 0x1B, 0x5C, and 0x7E

                              Set ISO-2022-JP output to false and return a code point whose @@ -2983,12 +2969,12 @@ and byte, runs these steps:

                            10. Let pointer be (ISO-2022-JP lead − 0x21) × 94 + byte − 0x21. -

                            11. Let code point be the index code point for +

                            12. Let codePoint be the index code point for pointer in index jis0208. -

                            13. If code point is null, return error. +

                            14. If codePoint is null, then return error. -

                            15. Return a code point whose value is code point. +

                            16. Return a code point whose value is codePoint.

                            end-of-queue @@ -3041,7 +3027,7 @@ and byte, runs these steps: lead byte.
                          28. -

                            If state is non-null, then: +

                            If state is non-null:

                            1. Set ISO-2022-JP decoder state and @@ -3085,91 +3071,80 @@ and byte, runs these steps: ASCII).

                              ISO-2022-JP's encoder's handler, given -ioQueue and code point, runs these steps: +ioQueue and codePoint, runs these steps:

                                -
                              1. If code point is end-of-queue and - ISO-2022-JP encoder state is not - ASCII, set - ISO-2022-JP encoder state to - ASCII, and return three bytes - 0x1B 0x28 0x42. +

                              2. If codePoint is end-of-queue and ISO-2022-JP encoder state is not + ASCII, then set ISO-2022-JP encoder state to + ASCII and return three bytes 0x1B 0x28 0x42. -

                              3. If code point is end-of-queue and - ISO-2022-JP encoder state is - ASCII, return finished. +

                              4. If codePoint is end-of-queue and ISO-2022-JP encoder state is + ASCII, then return finished.

                              5. -

                                If ISO-2022-JP encoder state is - ASCII or - Roman, and code point is U+000E, U+000F, - or U+001B, return error with U+FFFD. +

                                If ISO-2022-JP encoder state is ASCII or + Roman, and codePoint is U+000E, U+000F, or + U+001B, then return error with U+FFFD (�). -

                                This returns U+FFFD rather than code point to prevent attacks. +

                                This returns U+FFFD (�) rather than codePoint to prevent attacks. -

                              6. If ISO-2022-JP encoder state is - ASCII and code point is an - ASCII code point, return a byte whose value is code point. +

                              7. If ISO-2022-JP encoder state is ASCII and + codePoint is an ASCII code point, then return a byte whose value is + codePoint.

                              8. If ISO-2022-JP encoder state is Roman and - code point is an ASCII code point, excluding U+005C and U+007E, or is U+00A5 or - U+203E, then: + codePoint is an ASCII code point, excluding U+005C (\) and U+007E (~), or is + U+00A5 (¥) or U+203E (‾):

                                  -
                                1. If code point is an ASCII code point, return a byte - whose value is code point. +

                                2. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                                3. If code point is U+00A5, return byte 0x5C. +

                                4. If codePoint is U+00A5 (¥), then return byte 0x5C. -

                                5. If code point is U+203E, return byte 0x7E. +

                                6. If codePoint is U+203E (‾), then return byte 0x7E.

                                -
                              9. If code point is an ASCII code point, and - ISO-2022-JP encoder state is not - ASCII, - restore code point to +

                              10. If codePoint is an ASCII code point, and ISO-2022-JP encoder state + is not ASCII, then restore codePoint to ioQueue, set ISO-2022-JP encoder state to - ASCII, and return three bytes - 0x1B 0x28 0x42. + ASCII, and return three bytes 0x1B 0x28 0x42. -

                              11. If code point is either U+00A5 or U+203E, and - ISO-2022-JP encoder state is not - Roman, - restore code point to - ioQueue, set ISO-2022-JP encoder state to - Roman, and return three bytes - 0x1B 0x28 0x4A. +

                              12. If codePoint is either U+00A5 (¥) or U+203E (‾), and + ISO-2022-JP encoder state is not Roman, then + restore codePoint to ioQueue, set ISO-2022-JP encoder state to + Roman, and return three bytes 0x1B 0x28 0x4A. -

                              13. If code point is U+2212, set it to U+FF0D. +

                              14. If codePoint is U+2212 (−), then set it to U+FF0D (-). -

                              15. If code point is in the range U+FF61 to U+FF9F, inclusive, set it to the - index code point for code point − 0xFF61 in +

                              16. If codePoint is in the range U+FF61 to U+FF9F, inclusive, then set it to the + index code point for codePoint − 0xFF61 in index ISO-2022-JP katakana.

                              17. -

                                Let pointer be the index pointer for code point in +

                                Let pointer be the index pointer for codePoint in index jis0208.

                                If pointer is non-null, it is less than 8836 due to the nature of index jis0208 and the index pointer operation.

                              18. -

                                If pointer is null, then: +

                                If pointer is null:

                                1. If ISO-2022-JP encoder state is jis0208, - then restore code point to ioQueue, set + then restore codePoint to ioQueue, set ISO-2022-JP encoder state to ASCII, and return three bytes 0x1B 0x28 0x42. -

                                2. Return error with code point. +

                                3. Return error with codePoint.

                              19. If ISO-2022-JP encoder state is not jis0208, - restore code point to + restore codePoint to ioQueue, set ISO-2022-JP encoder state to jis0208, and return three bytes 0x1B 0x24 0x42. @@ -3178,8 +3153,7 @@ and byte, runs these steps:

                              20. Let trail be pointer % 94 + 0x21. -

                              21. Return two bytes whose values are lead and - trail. +

                              22. Return two bytes whose values are lead and trail.

                              @@ -3194,57 +3168,60 @@ and byte, runs these steps: ioQueue and byte, runs these steps:
                                -
                              1. If byte is end-of-queue and - Shift_JIS lead is not 0x00, set Shift_JIS lead to 0x00 and - return error. +

                              2. If byte is end-of-queue and Shift_JIS lead is not 0x00, then set + Shift_JIS lead to 0x00 and return error. -

                              3. If byte is end-of-queue and - Shift_JIS lead is 0x00, return finished. +

                              4. If byte is end-of-queue and Shift_JIS lead is 0x00, then return + finished.

                              5. -

                                If Shift_JIS lead is not 0x00, let lead be Shift_JIS lead, let - pointer be null, set Shift_JIS lead to 0x00, and then: +

                                If Shift_JIS lead is not 0x00:

                                  -
                                1. Let offset be 0x40 if byte is less than 0x7F, otherwise 0x41. +

                                2. Let lead be Shift_JIS lead. -

                                3. Let lead offset be 0x81 if lead is less than 0xA0, otherwise 0xC1. +

                                4. Set Shift_JIS lead to 0x00. -

                                5. If byte is in the range 0x40 to 0x7E, inclusive, or - 0x80 to 0xFC, inclusive, set pointer to +

                                6. Let pointer be null. + +

                                7. Let offset be 0x40 if byte is less than 0x7F; otherwise 0x41. + +

                                8. Let lead offset be 0x81 if lead is less than 0xA0; otherwise 0xC1. + +

                                9. If byte is in the range 0x40 to 0x7E, inclusive, or 0x80 to 0xFC, inclusive, + then set pointer to (leadlead offset) × 188 + byteoffset.

                                10. -

                                  If pointer is in the range 8836 to 10715, inclusive, return a code point whose - value is 0xE000 − 8836 + pointer. +

                                  If pointer is in the range 8836 to 10715, inclusive, then return a code point + whose value is 0xE000 − 8836 + pointer.

                                  This is interoperable legacy from Windows known as EUDC. -

                                11. Let code point be null if pointer is null, otherwise the +

                                12. Let codePoint be null if pointer is null; otherwise the index code point for pointer in index jis0208. -

                                13. If code point is non-null, return a code point whose value is - code point. +

                                14. If codePoint is non-null, then return a code point whose value is + codePoint. -

                                15. If byte is an ASCII byte, restore byte to +

                                16. If byte is an ASCII byte, then restore byte to ioQueue.

                                17. Return error.

                                -
                              6. If byte is an ASCII byte or 0x80, return a code point - whose value is byte. +

                              7. If byte is an ASCII byte or 0x80, then return a code point whose value is + byte. -

                              8. If byte is in the range 0xA1 to 0xDF, inclusive, return - a code point whose value is 0xFF61 − 0xA1 + byte. +

                              9. If byte is in the range 0xA1 to 0xDF, inclusive, then return a code point whose + value is 0xFF61 − 0xA1 + byte. -

                              10. If byte is in the range 0x81 to 0x9F, inclusive, or 0xE0 to 0xFC, - inclusive, set Shift_JIS lead to byte and return - continue. +

                              11. If byte is in the range 0x81 to 0x9F, inclusive, or 0xE0 to 0xFC, inclusive, then + set Shift_JIS lead to byte and return continue.

                              12. Return error.

                              @@ -3253,41 +3230,37 @@ and byte, runs these steps:

                              Shift_JIS encoder

                              Shift_JIS's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                                -
                              1. If code point is end-of-queue, return - finished. +

                              2. If codePoint is end-of-queue, then return finished. -

                              3. If code point is an ASCII code point or U+0080, return - a byte whose value is code point. +

                              4. If codePoint is an ASCII code point or U+0080, then return a byte whose + value is codePoint. -

                              5. If code point is U+00A5, return byte 0x5C. +

                              6. If codePoint is U+00A5 (¥), then return byte 0x5C. -

                              7. If code point is U+203E, return byte 0x7E. +

                              8. If codePoint is U+203E (‾), then return byte 0x7E. -

                              9. If code point is in the range U+FF61 to U+FF9F, inclusive, return - a byte whose value is code point − 0xFF61 + 0xA1. +

                              10. If codePoint is in the range U+FF61 to U+FF9F, inclusive, then return a byte + whose value is codePoint − 0xFF61 + 0xA1. -

                              11. If code point is U+2212, set it to U+FF0D. +

                              12. If codePoint is U+2212 (−), then set it to U+FF0D (-). -

                              13. Let pointer be the index Shift_JIS pointer for - code point. +

                              14. Let pointer be the index Shift_JIS pointer for codePoint. -

                              15. If pointer is null, return error with - code point. +

                              16. If pointer is null, then return error with codePoint.

                              17. Let lead be pointer / 188. -

                              18. Let lead offset be 0x81 if lead is less than 0x1F, otherwise 0xC1. +

                              19. Let lead offset be 0x81 if lead is less than 0x1F; otherwise 0xC1.

                              20. Let trail be pointer % 188. -

                              21. Let offset be 0x40 if trail is less than 0x3F, otherwise 0x41. +

                              22. Let offset be 0x40 if trail is less than 0x3F; otherwise 0x41. -

                              23. Return two bytes whose values are - lead + lead offset and +

                              24. Return two bytes whose values are lead + lead offset and trail + offset.

                              @@ -3306,39 +3279,43 @@ and byte, runs these steps: ioQueue and byte, runs these steps:
                                -
                              1. If byte is end-of-queue and - EUC-KR lead is not 0x00, set EUC-KR lead to 0x00 - and return error. +

                              2. If byte is end-of-queue and EUC-KR lead is not 0x00, then set + EUC-KR lead to 0x00 and return error. -

                              3. If byte is end-of-queue and - EUC-KR lead is 0x00, return finished. +

                              4. If byte is end-of-queue and EUC-KR lead is 0x00, then return + finished.

                              5. -

                                If EUC-KR lead is not 0x00, let lead be EUC-KR lead, let - pointer be null, set EUC-KR lead to 0x00, and then: +

                                If EUC-KR lead is not 0x00:

                                  +
                                1. Let lead be EUC-KR lead. + +

                                2. Set EUC-KR lead to 0x00. + +

                                3. Let pointer be null. +

                                4. If byte is in the range 0x41 to 0xFE, inclusive, set pointer to (lead − 0x81) × 190 + (byte − 0x41). -

                                5. Let code point be null if pointer is null, otherwise the +

                                6. Let codePoint be null if pointer is null; otherwise the index code point for pointer in index EUC-KR. -

                                7. If code point is non-null, return a code point whose value is - code point. +

                                8. If codePoint is non-null, then return a code point whose value is + codePoint. -

                                9. If byte is an ASCII byte, restore byte to +

                                10. If byte is an ASCII byte, then restore byte to ioQueue.

                                11. Return error.

                                -
                              6. If byte is an ASCII byte, return - a code point whose value is byte. +

                              7. If byte is an ASCII byte, then return a code point whose value is + byte. -

                              8. If byte is in the range 0x81 to 0xFE, inclusive, set - EUC-KR lead to byte and return continue. +

                              9. If byte is in the range 0x81 to 0xFE, inclusive, then set EUC-KR lead to + byte and return continue.

                              10. Return error.

                              @@ -3347,20 +3324,18 @@ and byte, runs these steps:

                              EUC-KR encoder

                              EUC-KR's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                                -
                              1. If code point is end-of-queue, return - finished. +

                              2. If codePoint is end-of-queue, then return finished. -

                              3. If code point is an ASCII code point, return - a byte whose value is code point. +

                              4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                              5. Let pointer be the index pointer for - code point in index EUC-KR. +

                              6. Let pointer be the index pointer for codePoint in + index EUC-KR. -

                              7. If pointer is null, return error with - code point. +

                              8. If pointer is null, then return error with codePoint.

                              9. Let lead be pointer / 190 + 0x81. @@ -3389,10 +3364,10 @@ the server and the client. byte, runs these steps:

                                  -
                                1. If byte is end-of-queue, return finished. +

                                2. If byte is end-of-queue, then return finished. -

                                3. If replacement error returned is false, set - replacement error returned to true and return error. +

                                4. If replacement error returned is false, then set replacement error returned to + true and return error.

                                5. Return finished.

                                @@ -3422,15 +3397,14 @@ rather the decode algorithm. UTF-16 lead byte and UTF-16 leading surrogate to null, and return error. -
                              10. If byte is end-of-queue and - UTF-16 lead byte and UTF-16 leading surrogate are null, return - finished. +

                              11. If byte is end-of-queue and UTF-16 lead byte and + UTF-16 leading surrogate are null, then return finished. -

                              12. If UTF-16 lead byte is null, set UTF-16 lead byte to - byte and return continue. +

                              13. If UTF-16 lead byte is null, then set UTF-16 lead byte to byte and + return continue.

                              14. -

                                Let code unit be the result of: +

                                Let codeUnit be the result of:

                                is UTF-16BE decoder is true @@ -3449,12 +3423,12 @@ rather the decode algorithm.
                              15. Set UTF-16 leading surrogate to null. -

                              16. If code unit is a trailing surrogate, then return a - scalar value from surrogates given leadingSurrogate and code unit. +

                              17. If codeUnit is a trailing surrogate, then return a + scalar value from surrogates given leadingSurrogate and codeUnit. -

                              18. Let byte1 be code unit >> 8. +

                              19. Let byte1 be codeUnit >> 8. -

                              20. Let byte2 be code unit & 0x00FF. +

                              21. Let byte2 be codeUnit & 0x00FF.

                              22. Let bytes be a list of two bytes whose values are byte1 and byte2, if is UTF-16BE decoder is true; otherwise byte2 and @@ -3463,12 +3437,12 @@ rather the decode algorithm.

                              23. Restore bytes to ioQueue and return error.

                              -
                            2. If code unit is a leading surrogate, then set - UTF-16 leading surrogate to code unit and return continue. +

                            3. If codeUnit is a leading surrogate, then set + UTF-16 leading surrogate to codeUnit and return continue. -

                            4. If code unit is a trailing surrogate, then return error. +

                            5. If codeUnit is a trailing surrogate, then return error. -

                            6. Return code point code unit. +

                            7. Return code point codeUnit.

                            @@ -3511,11 +3485,10 @@ https://stackoverflow.com/questions/6986789/why-are-some-bytes-prefixed-with-0xf byte, runs these steps:
                              -
                            1. If byte is end-of-queue, return - finished. +

                            2. If byte is end-of-queue, then return finished. -

                            3. If byte is an ASCII byte, return - a code point whose value is byte. +

                            4. If byte is an ASCII byte, then return a code point whose value is + byte.

                            5. Return a code point whose value is 0xF780 + byte − 0x80.

                            @@ -3524,19 +3497,18 @@ https://stackoverflow.com/questions/6986789/why-are-some-bytes-prefixed-with-0xf

                            x-user-defined encoder

                            x-user-defined's encoder's handler, given unused and -code point, runs these steps: +codePoint, runs these steps:

                              -
                            1. If code point is end-of-queue, return - finished. +

                            2. If codePoint is end-of-queue, then return finished. -

                            3. If code point is an ASCII code point, return - a byte whose value is code point. +

                            4. If codePoint is an ASCII code point, then return a byte whose value is + codePoint. -

                            5. If code point is in the range U+F780 to U+F7FF, inclusive, return - a byte whose value is code point − 0xF780 + 0x80. +

                            6. If codePoint is in the range U+F780 to U+F7FF, inclusive, then return a byte + whose value is codePoint − 0xF780 + 0x80. -

                            7. Return error with code point. +

                            8. Return error with codePoint.