Repository navigation
fix(entities): read pre-R2007 text in the code page the header names (§3.2.5, #370) - #374
Merged
Merged
Conversation
… not as lossy UTF-8 (§3.2.5, #370) One decode path, CodePage::decode, for every pre-R2007 string: the TV readers of tables, TEXT, ATTRIB, ATTDEF, MTEXT, TOLERANCE, IMAGEDEF, BLOCK and every object, the class table, the header variables and the metadata sections. The page is the header short at 0x13, stamped on each RawObject by the walker and put in force by decode_from_raw*. Two rows are measured against AutoCAD's exports (29 ANSI_1251, 30 ANSI_1252); any other number reads as before.
…ecode # Conflicts: # .github/workflows/ci.yml # ARCHITECTURE.md
… on patched copies (#370) The corpus holds no pre-R2007 string above 0x7F (0 of 9,076 strings in 24 drawings), so the decode is proved on 153 strings of 24 record kinds rewritten in memory: 612 of 612 reads match the Windows-1251 and Windows-1252 charts, and 51 table-entry names reach dwg-to-dxf as the matching escapes. Counts, oracle and probes did not move.
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. |
Owner
Author
|
Follow-up tracked in #375: code pages other than 1251/1252, a real-drawing proof (the pinned corpus has no pre-R2007 byte above 0x7F), R14, the writers' inverse, and XRECORD/XDATA strings. This PR stays scoped to the decode path and the two pages AutoCAD's exports name. |
5 tasks done
# Conflicts: # ARCHITECTURE.md
DrunkOnJava
enabled auto-merge (squash)
October 27, 2026 09:48
DrunkOnJava
added a commit
that referenced
this pull request
Oct 27, 2026
This was referenced Oct 27, 2026
DrunkOnJava
added a commit
that referenced
this pull request
Oct 27, 2026
…red table from the baseline (#376) * docs: bring README.md and RELEASE.md up to main, and render the measured table from the baseline README.md still showed the 2026-10-26 measurement: 13,781 decoded, 308 errored, 85.7 %, with the errors tracked in four issues that are now closed. main measures 15,527 decoded, 547 skipped and 0 errored on the 52 pinned drawings (96.6 %). The README now says that, lists the 30 skipped types with the open PR for each, gives the DXF value oracle's totals, and brings the capability matrix, the streaming section, the CLI list and the "does not do" list up to what has landed. The table and the totals are rendered from tools/corpus/baseline.tsv by tools/maintainer/readme_status.py (--write, --check). audit.py runs the check, and docs/maintaining.md adds housekeeping item 10: refresh the README after any landing that moves the baseline or ships a capability. STATUS.md's coverage line uses the same blocks. RELEASE.md cited a "#418" and "Q-07" that do not exist, listed five CLI tools where release.yml builds seven, and promised "4 binaries on 3 platforms" where it ships seven on five targets. It now names the twelve required checks and the README refresh as release steps. * docs: the README names #374 as landed and #375 as what remains of code pages * docs: render the DXF value oracle's totals from tools/oracle/baseline.tsv too The README's oracle line was typed by hand and went stale when #351 landed: 105,690 equal fields became 105,756. readme_status.py now renders it from the oracle baseline that CI pins, and --check covers it. * fix(tools): readme_status requires every marker block in both documents A STATUS.md edit that dropped or damaged its corpus-summary markers made --check pass with stale numbers, and --write left them untouched. Each document now lists the blocks it must carry. --check reports a block that is missing or doubled, and --write refuses to run until it is fixed. * docs: record #379 and #351, and re-render the numbers they moved #379 decoded the last two skipped types that had no decoder in progress, so every skipped type now has one in review, and #351 changed the oracle's totals. readme_status.py re-renders both, and the CHANGELOG gets the three 2026-10-27 entries the catch-up (#378) predates.
3 tasks
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
Pre-R2007 text is decoded in the code page the file header names (§3.2.5) through one shared path,
CodePage::decode, instead of as lossy UTF-8 at each reader. Closes #370.Spec reference
$DWGCODEPAGEof AutoCAD's own export of the same drawing (examples/probe_code_page.rs). It names two rows, 29 = ANSI_1251 (14 drawings) and 30 = ANSI_1252 (2 drawings). Any other number isCodePage::Unknown(n)and its text is read exactly as before. Windows-1250, 1253 to 1258, 874, 932, 936, 949 and 950 are not covered: no pinned drawing gives a number for them, and none is taken from memory or from a third-party implementation (CLEANROOM.md entry added).src/code_page.rs(new,encoding_rs0.8.35: MIT or Apache-2.0, BSD-3-Clause index data;cargo denypasses; builds on MSRV 1.85 and wasm32).RawObject::code_pageis stamped by the walker fromDwgFile::code_page();decode_from_raw*put it in force for the decode; the sharedTVreaders (tables, TEXT, ATTRIB, ATTDEF, MTEXT, TOLERANCE, IMAGEDEF, BLOCK, every object throughobjects::modern::read_tv), the class table, the header variables (Value::RawTextonly under an unnamed page) and the metadata sections read it back.dxf_header's$DWGCODEPAGEname now comes from the same table.(payload, body_start, inline_end, version); a parameter would rewrite all of them and every open PR that adds one.Evidence (real drawings, no unit tests)
The pinned corpus holds no pre-R2007 string with a byte above 0x7F: 3,418 / 2,846 / 2,812 strings decoded in the 8 AC1014 / 8 AC1015 / 8 AC1018 drawings, 0 with a high byte. The
94\U+00B0ofsample_AC1015's export is not one: the DWG's own MTEXT holds those nine ASCII characters (\U+00B0is MTEXT's escape for a character outside the page), so old and new decode agree with the export. Issue #370's premise that the DWG holds a 0xB0 byte there does not hold.So the path is proved on real drawings altered in memory (nothing written): 153 strings in 24 kinds of record of the 16 uncompressed drawings (AC1014 and AC1015) had their first four characters overwritten with
E9 B0 C0 FCat the bit they sit at, and were read back under the drawing's own header short and under 29, 30 and 31. 612 of 612 reads are what the Windows-1251 (29:й°Аь), Windows-1252 (30:é°Àü) and unknown-page (31: kept as before, counted) rules say, using the code page charts' characters and not the decoder's; 51 of 51 table-entry names reachdwg-to-dxfas the matching\U+XXXXescapes (they were\U+FFFD). The probe's first run found one reader that takes aRawObjectaround the dispatcher (tables::dimstyle::decode_with_vars, DIMSTYLE in DXF TABLES, 0 of 8); it now puts the record's page in force itself (8 of 8).Measured on the merged tree (main at 03e9e71 plus this branch), 2026-10-27, drawings under the pinned corpus (
tools/corpus/pins.tsv: 52 drawings, 18 acadsharp and 84 nextgis files):cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo test --release --all-featurescargo +1.85 check --all-features,cargo check --lib --target wasm32-unknown-unknowncargo deny check advisories bans licenses sources(0.19.4),cargo metadata --lockedfor the root,wasm/andfuzz/measure.py runthencheckdxf_oracle <corpus> --baseline tools/oracle/baseline.tsvprobe_header_vars,probe_dxf_header,probe_dxf_tables,probe_dxf_entities,probe_entity_colour,probe_text,probe_mtextspec_coverage.py --check,arch.py check,tools/streaming/check_invariants.pyprobe_code_page <corpus>Decoded, skipped and errored counts did not move, as expected: text content changes no field width.
Reproduce:
python3 -I tools/corpus/fetch.py --dest ../dwg-corpus && cargo run --release --example probe_code_page -- ../dwg-corpus; the Corpus job runs it (a CI step is added). Evidence section: ARCHITECTURE.md 7ao.Not in this change
dxf_tables::dash_text(landed with feat(dxf): write the ENTITIES section of 15 kinds, paired with AutoCAD's export (#126) #358, merged here) takes the record's page (ltype_groupsgetsRawObject::code_page); the corpus's complex linetypes have ASCII text, so no data exercises that line.Source-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:
My contribution is based on the ODA specification v5.4.1, AutoCAD's own DWG and DXF output in the pinned corpus, the Windows code page charts (for the expected characters of the probe), and the
encoding_rscrate as a dependency. No ACadSharp or ezdxf code, comments or data were read for the code page numbers (CLEANROOM.md, 2026-10-27).Developer Certificate of Origin
By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.