Repository navigation
craft-dxf: R12 binary, more code pages, borrowing sections, exponent reals (ports of open CadCraft PRs) - #847
Merged
Merged
Conversation
Only a string with a backslash can hold a \U+ or \M+ escape; every other string moves into the tag as it is instead of being copied. The EOF check reads the value before it moves. Ported from storytold/cadcraft#1833.
… fallback write_ascii_in falls back to pure ASCII when the code page bytes happen to be valid UTF-8, for readers that guess UTF-8. A reader that decodes a pre-2007 DXF strictly by its $DWGCODEPAGE needs the code page bytes. Ported from storytold/cadcraft#2851.
Exact group-code mappings in one place, documented errors on the fallible public parsers, and simpler option, result and formatting idioms. No change to parsing, writing, numeric conversion, encoding or the public API. Ported from storytold/cadcraft#2571.
Binary DXF written before R13 stores each group code in one byte, with 255 escaping a 2-byte code. The reader only knew the R13+ layout, where codes are two bytes, and also treated 255 as an escape there. The layout is now told from the first tag; 255 is an escape only in the 1-byte layout and an ordinary code in R13+. Ported from storytold/cadcraft#1499.
…ead of copying sections() and records() copy every tag out of the parsed list, so a reader that keeps the list holds a large file's tags two or three times. The new functions return slices of the list. sections() and records() now build their copies from them, so there is one implementation of each split. Ported from storytold/cadcraft#1708. storytold/cadcraft#1588 solves the same problem by changing Section itself; this keeps the existing API.
…orm; string_groups format_real wrote f64::MAX as 309 digits. Values outside 1e-10..1e16 are now written as AutoCAD writes them (1.0E+20) and read back exactly. string_groups splits text into the 250-character groups long strings are stored in (MAX_STRING_CHARS). Ported from storytold/cadcraft#1790.
…59-15 code pages; cheaper unescape and hex $DWGCODEPAGE values DOS720, 737, 775, 855, 857, 860, 861, 863, 864, 865, 869 and ISO8859_15 had no decoder and fell back to Windows-1252. ISO 8859-15 decodes through encoding_rs, the DOS pages through tables checked against the Unicode Consortium mapping files (dos_tables.rs). DOS 864's byte 0x25 is U+066A, so a writer escapes '%' there. U+FFFD is never written as a table byte. A string without an escape moves into its tag without a copy, cstr finds its terminator with one scan, and binary chunks are hex-encoded from a table. Ported from storytold/cadcraft#1271. Its group-code-255 change is carried by the R12 binary port: the 1-byte layout is detected only when the escaped code is one that needs the escape, so an R13+ file starting with code 255 still reads.
Johab had no decoder: files declaring ANSI_1361 were read as Windows-1252 and \M+4 escapes stayed literal. Hangul syllables are composed from the three 5-bit jamo indices (KS X 1001 annex 3); symbols and Hanja map onto KS X 1001 rows decoded as EUC-KR. Read only: a writer escapes instead. Ported from storytold/cadcraft#1911 (its DOS code pages are covered by the tables from storytold/cadcraft#1271).
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
This was referenced Nov 11, 2026
mbolling
added a commit
to mbolling/cadcraft
that referenced
this pull request
Nov 12, 2026
main now reads DXF through craft-dxf (storytold#3040) and no longer carries crates/dxf, so this branch's change to that crate is dropped: it is in craft-dxf already (storytold/craft-libs#847) and reaches cadcraft with the next pin. The text helper in crates/io takes the renamed crate path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.



What this is
Open CadCraft pull requests that change
crates/dxf, the copy cadcraft#3040 deletes. This carries their DXF parts here, one commit per source PR, each with its original author.What changed (
crates/dxf)write_ascii_in_pagewrite_ascii_inwithout its fallback to pure ASCII, for a reader that decodes strictly by$DWGCODEPAGE. Additive.section_slices,record_slices,Tag::str_refsectionsandrecords, so a reader does not hold a large file's tags two or three times.sectionsandrecordsnow build their copies from these. Additive.string_groupsformat_realwrotef64::MAXas 309 digits. Values outside 1e-10..1e16 are written as1.0E+20and read back exactly.string_groupsandMAX_STRING_CHARSsplit text into 250-character groups.DOS720, 737, 775, 855, 857, 860, 861, 863, 864, 865, 869 andISO8859_15decoded as Windows-1252. New tables indos_tables.rs, checked against the Unicode Consortium mapping files (noted in the file). DOS 864%and U+FFFD are escaped on write, as the reviews there asked. Cheapercstr, hex and unescape.ANSI_1361/JOHABtext and\M+4escapes decode. Read only.Where the ports differ from their sources
format_real(1e21)is plain digits; tga, dpx: test the RGBA8 encoders' allocation-failure path #1790 makes it1.0E+21. The test follows tga, dpx: test the RGBA8 encoders' allocation-failure path #1790.oem_cpcrate for the DOS pages. Those come from craft-docx: read and write the hide spelling and grammar errors settings #1271's tables instead, so there is no new dependency.DOS862(Hebrew), which only craft-video: Hap video decoder and encoder (#1519) #1911 had, is not included.unescape_owned(same effect, no copy).Not ported (left for a decision)
Sectionbecomes a borrowed view): same goal as craft-psd: share raw Duotone ink records and block writer #1708 but changes the existingSectiontype. The additive API here covers it.TagStream, parse while the file is written): written against the single-pass binary reader. The reader here parses binary files in two passes when a code page is ambiguous, so the stream needs a redesign, not a port.write_ascii_as; needs redoing on the current writer.parse_recovering): no tests, stops silently at the tag limit, and skipping a corrupt line can pair a value line with the wrong code.Behaviour changes
format_realoutput for magnitudes outside 1e-10..1e16 changes form (same value).Checks run
cargo test -p craft-dxf: 77 passed, 2 ignored (pre-existing ignores).cargo clippy -p craft-dxf --all-targets -- -D warnings: clean.cargo fmt --check -p craft-dxf: clean.Checks not run
Workspace-wide tests. CadCraft's own io tests against this branch (cadcraft#3040 is the switch). No third-party R12 binary or Johab files; the tests build their inputs.