Repository navigation
feat(iconv): code pages via encoding_rs (iconv_charsets feature) - #2941
Merged
Merged
Conversation
Adds windows-125x, iso-8859-x, koi8, macintosh and the CJK sets from the WHATWG tables, behind a default-on `iconv_charsets` feature (absent from the browser wasm package, like tzdata). Built-in names win; WHATWG labels that alias latin1/ascii to windows-1252 resolve to the real charsets. Errors keep exact byte positions; unmappable chars never become NCRs. Closes #2935
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
Part 2 of #2935, following #2937. Closes #2935.
What changed
iconvgains the WHATWG Encoding Standard charsets: windows-874 and windows-1250 to 1258, iso-8859-2 to 16, koi8-r/u, macintosh, ibm866, Shift_JIS, EUC-JP, ISO-2022-JP, GBK, GB18030, Big5 and EUC-KR. Common GNU spellings also work (latin9,cp936,cp932,eucjp, ...).iconv -llists them.encoding_rs, behind a newiconv_charsetsfeature. It is on by default, listed bybashkit-cliandbashkit-capi, and absent frombashkit-wasm, the same way astzdata. Without the feature,iconvrefuses these charsets with exit 1.latin1,iso-8859-1andasciito windows-1252, so every windows-1252 label that is not spelled 1252 resolves to real Latin-1 or ASCII instead.-c. They are never turned into&#NNN;HTML references.Why
The main case in #2935: Excel exports in cp1252 or cp1250 (
iconv -f cp1252 -t utf-8 export.csv→iconv: unsupported encoding 'cp1252').Before / After
A new differential test checks the output bytes and exit codes against glibc
iconvfor cp1252 and cp1250 in both directions, iso-8859-15, GBK, and a Shift_JIS round trip.Risk
bashkit's default build, but it was already in the lockfile (via markkit) with asafe-to-deployexemption. Its license is (Apache-2.0 OR MIT) AND BSD-3-Clause, which is allowed.Checklist
replacementencoding refused, every byte through every charset with no panic), plus 1 differential integration test. The lib tests also pass with--no-default-features.