Repository navigation
feat(objects): read XRECORD values and extended entity data in the code page each string names (§28, §20.4.104, #375) - #380
Conversation
…de page each string names (§28, §20.4.104, #375) extended_data::read turns a record's extended entity data chain into values, and extended_data::xrecord_values an XRECORD's body, for R13 to R2004, each string decoded by CodePage::decode in the page its own byte names. The string layout, the handle byte orders and the value widths are measured against AutoCAD's exports: 1,209 of 1,209 compared records agree, and every one of 78,242 strings names its header's page.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29e0eddddd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ck export-only extended data (#375) A save-time handle or GUID ended the XRECORD comparison there and any handle difference was accepted, and a record whose chain the reader returned empty was never compared with the export. Differences are now accepted only in the two records and for the three values the save makes anew, under the same group code, and the rest of the record is still compared; application data the export holds for a record the reader returned nothing for fails the probe unless it is the table header's DbSaveVer item. The probe also refuses to report when it paired nothing or patched no XRECORD or extended data string.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62d10d5fb5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # ARCHITECTURE.md # CLEANROOM.md
…Al block to be missing (#375) Applications are paired by identity: each application of the export, named by its group 1001, with the decoded application whose handle resolves through the drawing's APPID entries to the same name, so a wrong application handle fails the probe. The only leading items the export may lack are exactly the RTTcAl block (a string, a short, a long and $$NoName$$) of the two R2000 MTEXT records that carry it, and a decoded application the export omits altogether is counted, 45 on the pinned corpus.
…o fix/xrecord-xdata-code-page
…RTTcAl block (#375) The exception for the leading RTTcAl block now names its application and its record kind as well as its shape; everywhere else the export's values must equal the decoded ones from the first item. Probe result on the 52 pinned drawings unchanged: 1,211 of 1,211 records agree.
# Conflicts: # ARCHITECTURE.md
…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.
…s (§3.2.5, #375) (#382) * feat(writer): write the drawing's code page, not UTF-8 or bare escapes (§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. * fix(code_page): encode a character only when its bytes decode back to 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. * docs(architecture): the merged probe's patched-copy numbers, XRECORD 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.
…rove, and pin three public sources (§3.2.5, #375) (#384) * feat(writer): write the drawing's code page, not UTF-8 or bare escapes (§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. * fix(code_page): encode a character only when its bytes decode back to 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. * feat(code_page): name the header shorts 28 to 41 that real drawings prove, and pin three public sources (§3.2.5, #375) The short at 0x13 is AutoCAD's own enumeration, not a Windows code page number. Eight rows are added, each backed by a drawing: 38 and 39 by the localized layout name decoding in the nine newly pinned drawings (kurema/BookViewerApp3 MIT, Seeed-Studio/OSHW-Jetson-Series and huifer/planar_algorithm Apache-2.0), and 28, 32, 33, 36, 40 and 41 by local-only evidence recorded by sha256 in ARCHITECTURE.md (DXF twins that name the page, Greek and Korean text). fetch.py percent-encodes the path of a file. The probe pairs the header short of every release with its export, checks the known texts, counts the strings that occur in the export, and lists the drawings whose strings hold a \U+ or \M+ escape. * test(corpus): ratchet the nine new pinned drawings, nine BLOCK_HEADER errors included (#375) Regenerated from the corpus-measurement artifact of the Corpus job: the 52 existing rows are unchanged, the nine new rows decode 106,189 records, skip 90 and error on 9 BLOCK_HEADER records of the four AutoCAD I.18.0.0 drawings, which ARCHITECTURE.md now says. * docs(code_page): point the module docs at this change's ARCHITECTURE section (#375) The two references said 7aq, which on main is the PERSSUBENTMANAGER section; the rows section is 7ar. * docs(architecture): the merged probe's patched-copy numbers, XRECORD 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.
….52, #386) (#388) * feat(writer): write the drawing's code page, not UTF-8 or bare escapes (§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. * fix(code_page): encode a character only when its bytes decode back to 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. * feat(code_page): name the header shorts 28 to 41 that real drawings prove, and pin three public sources (§3.2.5, #375) The short at 0x13 is AutoCAD's own enumeration, not a Windows code page number. Eight rows are added, each backed by a drawing: 38 and 39 by the localized layout name decoding in the nine newly pinned drawings (kurema/BookViewerApp3 MIT, Seeed-Studio/OSHW-Jetson-Series and huifer/planar_algorithm Apache-2.0), and 28, 32, 33, 36, 40 and 41 by local-only evidence recorded by sha256 in ARCHITECTURE.md (DXF twins that name the page, Greek and Korean text). fetch.py percent-encodes the path of a file. The probe pairs the header short of every release with its export, checks the known texts, counts the strings that occur in the export, and lists the drawings whose strings hold a \U+ or \M+ escape. * test(corpus): ratchet the nine new pinned drawings, nine BLOCK_HEADER errors included (#375) Regenerated from the corpus-measurement artifact of the Corpus job: the 52 existing rows are unchanged, the nine new rows decode 106,189 records, skip 90 and error on 9 BLOCK_HEADER records of the four AutoCAD I.18.0.0 drawings, which ARCHITECTURE.md now says. * docs(code_page): point the module docs at this change's ARCHITECTURE section (#375) The two references said 7aq, which on main is the PERSSUBENTMANAGER section; the rows section is 7ar. * fix(tables): read the whole insert-count run of a BLOCK_HEADER (§20.4.52, #386) * docs(architecture): the merged probe's patched-copy numbers, XRECORD 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. * docs(arch): number the BLOCK_HEADER section after the code page sections (#386) * chore(corpus): commit the baselines CI run 40573732934 measured * docs(architecture): drop the second copy of section 7au the merge with #384's squash appended * chore(corpus): commit the baselines CI run 40576136864 measured
…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
Summary
Reads the two places that hold pre-R2007 text the crate never turned into a string, XRECORD data and extended entity data, as values, with each string decoded in the code page its own page byte names (#375, the XRECORD/XDATA item).
XRecord::datastays raw bytes andcommon_entity::skip_extended_datais untouched; the newsrc/extended_data.rsaddsextended_data::read(the extended data chain of a walked record) andextended_data::xrecord_values(an XRECORD), for R13 to R2004. R2007 and later (UTF-16) returnError::Unsupported.Spec reference
ODA spec v5.4.1 §28 (extended entity data) and §20.4.104 (XRECORD); the code page of each string, §3.2.5 and
src/code_page.rs(#374). ARCHITECTURE.md §7aq (provisional letter; the integrator renumbers).The specification's two string layouts are one in the data. §20.4.104 says "the string length (RC), the dwgcodepage (RC), and then the string" and §28 "1st byte of value is the length N; this is followed by a 2-byte short indicating the codepage": on every pre-R2007 drawing of the pinned corpus both are the same three bytes before the characters, an
RSlength and anRCpage. No string is 256 bytes or longer (the longest is 250), so the data cannot tell theRSform from anRCfollowed by a short; the reader takesRS, the form that reads every XRECORD to its last byte. XRECORD value widths follow the DXF group code ranges of Autodesk's public DXF Reference, only for ranges whose codes occur in the corpus; any other code isError::Unsupported, never read at a guessed width (disclosed in CLEANROOM.md).Corpus measurement (
tools/corpus/measure.py check, 52 pinned drawings): every row matches the baseline, so no baseline is regenerated (no decoded, skipped or errored count moves:XRecordand the skip path are unchanged).Evidence (
cargo run --release --example probe_code_page -- ../dwg-corpus, 2026-10-27; 24 pre-R2007 drawings of the 52):#306(a handle) and#D09(a GUID and the saved file's path) may differ, under the same group code, with the rest of each record still comparedRTTcAlblock; 1 is the VPORT table header#8, whoseDbSaveVeritem only the export holds), R2004 347 of 347 (1 export-only)Not measured, and said so in ARCHITECTURE.md: R2007+ strings; XRECORD codes outside the measured ranges; a length of 256 bytes or more; extended data of an application the export omits. R14 has no export that names a page, so R14 rests on the same shorts meaning there what they mean later (the strings of the R14 drawings name 29 and 30, as their headers do).
Overlap with #372 (DXF OBJECTS, adds its own
XRecord::items): this PR touchessrc/objects/xrecord.rsnot at all, so the two do not conflict by file today. #380 lands first (queued behind #376); the header lane resolves thesrc/objects/xrecord.rsconflict when it restacks #372 onto main, to one decode path (one place a pre-R2007 byte string becomes aString:CodePage::decode, each string reading its own page byte).extended_data::xrecord_valuesandXRecord::itemsthen collapse to one reader, andprobe_code_pageand the DXF OBJECTS probe are rerun on that side.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,cargo test --release --all-features(921 passed, 0 failed), MSRVcargo +1.85 check --all-features, wasm32cargo check --lib,cargo deny check advisories bans licenses sourcespass locally on this headprobe_code_pageover the 52 pinned drawings (numbers above); the DXF oracle againsttools/oracle/baseline.tsv;probe_header_vars,probe_dxf_header,probe_dxf_tables,probe_dxf_entities,probe_dxf_classes,probe_entity_colour,spec_examplesat 0 differences;measure.py check(52 of 52 rows)python3 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 layouts come from AutoCAD's own output alone: AutoCAD-written DWG files compared with AutoCAD-written DXF exports of the same drawing, from the pinned public corpus (nextgis/dwg_samples, ACadSharp samples/), as recorded in CLEANROOM.md (2026-10-27). The XRECORD group code widths come from Autodesk's 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.