Repository navigation
feat(writer): write the drawing's code page, not UTF-8 or bare escapes (§3.2.5, #375) - #382
Merged
Merged
Conversation
…s (§3.2.5, #375) CodePage::encode is decode's inverse (a character the page holds is its byte, any other the \U+XXXX escape AutoCAD's own R2000 and R2004 saves hold). convert_dwg_to_dxf_bytes and dwg-to-dxf write R12 to R2004 in the drawing's page, the class table writer encodes through the page in force, and the R2004-family header carries the page again, so DwgFile::to_bytes keeps the text readable.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… it (#375) The WHATWG encoders map a few extra code points onto bytes the decoder reads as another character (U+00A5 to 0x5C and U+203E to 0x7E on Shift_JIS, U+0080 on Shift_JIS, U+20AC on GBK). encode_char now returns the bytes only when decode gives the character back, so those characters take the escape and a written string reads as the text it was. The 128 of 128 round trip of each named page in probe_code_page is the same check over the whole page.
3 tasks done
# Conflicts: # ARCHITECTURE.md # examples/probe_code_page.rs
…and extended data strings included (#375) With #380 on main the probe also patches XRECORD and extended data strings, and the R2004 drawings through the DWG writer: 266 strings in 27 kinds, 1,064 of 1,064 reads, 348 of 348 DXF name checks; XRECORD values 24 strings 96 of 96, extended data 3 strings 12 of 12.
DrunkOnJava
enabled auto-merge (squash)
October 27, 2026 17:15
This was referenced Oct 27, 2026
Merged
DrunkOnJava
added a commit
that referenced
this pull request
Oct 28, 2026
…10-27 (#416) * docs: bring README, ROADMAP and CHANGELOG up to the landings of 2026-10-27 README's code-page and DXF writer text named work in review that has landed (#371, #380, #382, #384); jev_review.py prose ranked those sentences 0.72 to 0.96. ROADMAP's "where it stands" table was a 2026-10-21 snapshot whose numbers, CI row and release row were all out of date; it now points to the rendered numbers instead of repeating them. CHANGELOG gains #371, #380, #382, #384, #385 and #404. * docs(changelog): record the CI-only merge train (#408) * docs: OBJECTS landed (#372): README, ROADMAP and CHANGELOG * docs: LAYOUT, GROUP and MLINESTYLE (#373), the class map writer (#405) and the double-byte round trip (#414) landed * docs: VISUALSTYLE landed (#413) * docs(readme): name the skipped types still in review without per-type counts; MATERIAL landed (#325) * docs(readme): point to the open decoder PRs instead of a list that each landing makes stale
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.
Summary
The inverse of #374 (#375, the writers' item):
dwg-to-dxfand the DWG writer now write a pre-R2007 drawing's text in the drawing's own code page instead of UTF-8 or bare escapes.CodePage::encode_charandencodeturn a character the page holds into its byte (two on a double-byte page) and any other into AutoCAD's\U+XXXX;convert_dwg_to_dxf_bytes(andconvert_file_to_dxf_bytes, and the binary) write R12 to R2004 in that page;classes::write_tvencodes through the page in force;file_writer::assemble_dwg_bytes_with_pagewrites the page into the header (the short at 0x13) andDwgFile::to_bytespasses the drawing's own, so a rewritten file no longer reads its own text as an unnamed page (it wrote 0).convert_dwg_to_dxfstill returns aString, so it keeps escapes only.Spec reference
ODA spec v5.4.1 §3.2.5 (the code page short, via #374); ARCHITECTURE.md §7ar (provisional letter; the integrator renumbers).
Corpus measurement (
tools/corpus/measure.py check, 52 pinned drawings): no decoded, skipped or errored count moves, so no baseline is regenerated; the DXF oracle matchestools/oracle/baseline.tsv.Evidence (
cargo run --release --example probe_code_page -- ../dwg-corpus, 2026-10-27; the 24 pre-R2007 drawings of the 52):encodeagainstdecode, every byte above 0x7F of each named pageANSI_1251and forANSI_125294\U+00B0dwg-to-dxf(R2000 target, bytes)DwgFile::to_byteson the R2004 familysample_AC1021,1024,1027,1032)\U+220545,6as AutoCAD wrote it)convert_dwg_to_dxf_bytesagainstconvert_dwg_to_dxf(R2000 and R2004 targets)What AutoCAD does is measured for two cases only, said so in ARCHITECTURE.md: an in-page character is its byte in a pre-R2007 DXF (one raw
0xD8in a TEXT of the R12 exportsample_AC1009_ascii.dxf; none in an R2000 or R2004 export), and a character the page lacks is\U+XXXX(the diameter sign U+2205: the R2007+ saves hold the character, the R2000 and R2004 saves hold the escape, in an MTEXT and an XRECORD string). Still owed: TEXT, ATTRIB or name text outside its page, MTEXT in an R2000 or R2004 DXF target (the ENTITIES writer does not write it yet), characters above the BMP, and a strings encoder for entities (the DWG writer writes no entity strings).The first run of the bytes-against-String check read 0 of 104 and found a real defect: four
999comments the writer itself emits indxf_sections.rsheld an em dash or a≈, which a pre-R2007 DXF reads as bytes of the code page, not UTF-8. They are ASCII now, and a character above U+00FF that still reaches the bytes conversion becomes an escape, never?.README.md and STATUS.md are not refreshed here:
tools/maintainer/readme_status.pyis not onmainyet (#376 adds it), so the integrator regenerates them after this lands.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features, MSRVcargo +1.85 check --all-features, wasm32cargo check --lib,cargo deny check advisories bans licenses sourcespass locally on this head;cargo test --release --all-featuresran green on the pre-rebase head and runs in CI on this oneprobe_code_pageover the 52 pinned drawings (numbers above); the DXF probes callconvert_dwg_to_dxfunchanged and read 0 differencespython3 tools/ci/spec_coverage.py --checkandpython3 tools/maintainer/train/arch.py checkpassSource-provenance declaration
By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:
CLEANROOM.md).dwg-rsis Apache-2.0 and must remain compatible.My contribution is based on:
CLEANROOM.md.See
CLEANROOM.mdfor the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.For this PR specifically: the behaviours come from AutoCAD's own output alone (AutoCAD-written DWG and DXF files of the pinned public corpus). That a DXF before R2007 is read in
$DWGCODEPAGEis the Autodesk public DXF Reference (recalled; dated entry in CLEANROOM.md). No code of any other DWG implementation was read.Developer Certificate of Origin
By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.
I will sign off commits with
git commit -swhen asked, which adds aSigned-off-bytrailer to the commit message asserting the DCO.