replacement

replacement (文字コード)

仕様書

ラベル

[23] 次のラベルreplacement を表します。

[24] かつては、他の符号化とは違って、名前 replacementラベルではありませんでした。しかしその後 replacement ラベルが追加されました >>26

文脈

[7] replacementは、 サーバークライアントとで異なる符号化に対応している場合に、 それを使って攻撃されることを防ぐため、 使われています。 >>6

[9] 過去にどこかで使われていたものの、現在の Web では互換性のためにも不要と判断される符号化が指定された時に、 かわりに使われます。

[10] hz-gb-2312 は、かつて中華人民共和国で使われていた文字コードです。 電子メールなどだけでなく、 Web でもごく限られた範囲で用いられたことがありました。 hz-gb-2312非ASCII文字ASCII文字の範囲で表現できるという特徴をもって設計されたものですが、 それが攻撃に悪用されるおそれがあります。

[8] 著者が意図的に replacement を使う必要も、利点もありません。

符号化

[11] 符号化器はありません。Webプラットフォームにおいて、 replacement文字列符号化することはありません。

[21] 著者replacement を指定した場合、かわりに UTF-8 が使われます。 符号化の特殊例の項を参照。

復号

[22] replacement復号は、 入力が空バイト列なら空文字列を返し、 それ以外なら U+FFFD (誤りモードfatal なら誤り) を返します。

[25] TextDecoderreplacement に対応しておらず、例外投げられます。


[12] 復号器は、 replacement error returned flag を持ちます。 既定値はです。 >>6

[13] 復号器取扱器は、ストリームバイトについて、 次のようにします。 >>6

  1. [14] バイトend-of-stream の場合、
    1. [15] 終了済みを返します。
  2. [16] それ以外で、replacement error returned flagの場合、
    1. [17] replacement error returned flag を、に設定します。
    2. [18] 誤りを返します。
  3. [19] それ以外の場合、
    1. [20] 終了済みを返します。

歴史

[1] Introduce a replacement encoding as a trial balloon to fixing various is... · 8329a2e · whatwg/encoding ( ( 版)) <https://github.com/whatwg/encoding/commit/8329a2e768caea6908d600debd3cc8a6dc59c3c3>

[2] Issue 265973003: Implement "replacement" text encoding. - Code Review ( ( 版)) <https://codereview.chromium.org/265973003>

[3] Fix #33: handle empty input better for the replacement decoder · whatwg/encoding@4e8e211 ( 版) <https://github.com/whatwg/encoding/commit/4e8e2111c45e02934b36bbce51157d3dbb322242>

[4] Fix #29: introduce output encoding for URL and HTML forms · whatwg/encoding@02c55f2 ( 版) <https://github.com/whatwg/encoding/commit/02c55f23fc1968f68472d3e82e5da29c4fe0ec65>

[5] Update integration with Encoding Standard · whatwg/html@6a31c26 ( 版) <https://github.com/whatwg/html/commit/6a31c26cf12e39dab1a488e75dd56c03d6786d39>

[26] Add "replacement" as label for the replacement encoding (annevk著, ) <https://github.com/whatwg/encoding/commit/ee357f3f192b956169a2ed6fba76abe69c23e24f>

[27] Add "replacement" as label for the replacement encoding by annevk · Pull Request #117 · whatwg/encoding () <https://github.com/whatwg/encoding/pull/117>

[28] Add "replacement" as a label for the replacement encoding · Issue #70 · whatwg/encoding () <https://github.com/whatwg/encoding/issues/70>