Repository: lifthrasiir/rust-encoding (language: rust)

Issue:
hz-gb-2312 encoding and WHATWG compatibility
The WHATWG Encoding Spec [lists hz-gb-2312](https://encoding.spec.whatwg.org/#names-and-labels) as mapping to [the replacement encoding](https://encoding.spec.whatwg.org/#replacement), which uses the UTF-8 encoder and throws a special replacement encoding error for its decoder. However, it looks like this crate implements the actual HZ encoding. For WHATWG compatibility, this would have to get folded in with the rest of the replacement encodings, but I don't know if that's acceptable considering other people may be using the current implementation.

Would you prefer to maintain strict WHATWG compatibility or keep the current implementation? If the current implementation is kept, this deviation needs to be well documented - it isn't too hard to work around, but is a bit annoying and could catch someone unaware because the rest of the crate is compatible.



Discussion / hints:
Confirmed. This is another piece of change I've missed. It would be enough to fix the `encoding_from_whatwg_label` and `whatwg_name`.

Any deviation from the _current_ WHATWG specification is unintentional and to be fixed. Please file an issue or PR dealing with such deviations. (I'm kind of lazy and not always aware of all changes to the specification, but I think at some point I have implemented all encodings in the specification correctly.)

Haha, I went through the whole spec and this is the last one I've found with regard to names and labels. Do you just want to ...rip out the entire HZ implementation though? I think it'd be a shame to throw it away/not expose it some other way.

@aneeshusa I want to keep the encoding, simply making it invisible from `encoding_from_whatwg_label`.

OK, that's reasonable. I can put in a PR for that in a few minutes (it should be only a line, I think.)


Fix patch:
diff --git a/src/label.rs b/src/label.rs
index 483c6c93..8e43c89f 100644
--- a/src/label.rs
+++ b/src/label.rs
@@ -225,8 +225,6 @@ pub fn encoding_from_whatwg_label(label: &str) -> Option<EncodingRef> {
         "iso-ir-58" |
         "x-gbk" =>
             Some(all::GB18030 as EncodingRef),
-        "hz-gb-2312" =>
-            Some(all::HZ as EncodingRef),
         "big5" |
         "big5-hkscs" |
         "cn-big5" |
@@ -260,6 +258,7 @@ pub fn encoding_from_whatwg_label(label: &str) -> Option<EncodingRef> {
         "windows-949" =>
             Some(all::WINDOWS_949 as EncodingRef),
         "csiso2022kr" |
+        "hz-gb-2312" |
         "iso-2022-kr" |
         "iso-2022-cn" |
         "iso-2022-cn-ext" =>


Test patch: