Repository navigation
fix(iconv): write real bytes, add -o, -c and //IGNORE - #2937
Merged
Merged
Conversation
iconv built its output as a String, so -t latin1 wrote UTF-8 again and -t utf-16 went through a lossy decode. Convert char by char from input bytes to output bytes, report GNU byte positions, keep the converted prefix on error. UTF-16LE/BE write no BOM. -o writes only after a full conversion. -c and //IGNORE drop bad input and unconvertible chars and exit 1. Output growth is charged to the execution budget. Refs #2935
Review summary — iconv real-bytes + -o/-c (2937@dda0fd23, rebase follow-up)Verdict: no new findings. This push looks like a rebase onto Prior findings remain resolved; no new review posted. Context re-verified from the snapshot: |
Address review: -c -o FILE intentionally writes the converted rest (the point of -c); the header and usage now say so and an in-place test pins it. -s and empty //, suffixes match glibc 2.39; tests pin both.
…-cs5tvz # Conflicts: # knowledge/log.md
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 7266fce | Commit Preview URL Branch Preview URL |
Nov 18 2026, 06:09 PM |
This was referenced Nov 18, 2026
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 1 of #2935 (code pages follow in a separate PR).
What changed
iconvnow outputs raw bytes:-t latin1writes Latin-1 bytes and-t utf-16*writes real UTF-16 code units. Before, output went back through aString.UTF-16output has a BOM and is little-endian.UTF-16LEandUTF-16BEhave no BOM, as in GNU. Before,utf-16lewas an alias of the BOM form.illegal input sequence at position N,incomplete character or shift sequence at end of buffer). The part converted before the error still goes to stdout, with exit 1.-o FILEis not written when conversion stops on an error.iconv -f X -t Y -o in.csv in.csvwith a wrong-fguess leaves the file as it was.-cand//IGNOREdrop invalid input bytes, characters the target cannot hold, and a character cut off at the end of the input. They convert the rest and exit 1. With-o, the rest is still written, because dropping was requested. That is how a damaged export gets saved.//TRANSLITnow only applies to characters the target cannot hold, solatin1//TRANSLITkeepsé. It now covers multi-character spellings (ß→ss,€→EUR) and quotes and dashes. Characters it does not know become?.-fX,--from-code=X,--to-code,--outputand-sare accepted.-sand empty suffixes behave as in glibc.od.Why
Excel and Windows CSV exports are not UTF-8. Text builtins replace invalid UTF-8 with
�(L-STREAM-001), soiconvis the step that has to work beforeawk,sedorcutcan read these files. It could not repair double-encoded text, and it damaged UTF-16 output.Before / After
A new differential test checks the output bytes and exit codes against the host's glibc
iconvfor UTF-16 (with BOM, BE, surrogates), Latin-1 in both directions, and a truncated input.The
-cexit status is the one intended difference. POSIX and GNU libiconv exit 1, and glibc 2.39 exits 0. This is recorded as L-ICONV-001.Risk
iconvbuiltin.-t latin1returning UTF-8 text will now get Latin-1 bytes, which is the intended fix.Checklist
byte_stream_teststhreat_model_tests::resource_exhaustion::bounded_*fails 6 tests locally on unmodified main too. It depends on the environment and is not related to this change.