Create a pair reader from DXF bytes (ASCII or binary).
ASCII path encoding strategy (hybrid of byte-trust and header sniffing):
An explicit options.encoding always wins — the caller asserts the
encoding, no sniffing contradicts it. Non-UTF-8 overrides decode
line-by-line (never a single full-file string).
Otherwise the bytes are strictly validated as UTF-8. Valid UTF-8
(including pure ASCII) decodes correctly regardless of any stale
$DWGCODEPAGE, so the header is never consulted — modern files skip
the header pre-scan entirely and stream straight from bytes.
Invalid UTF-8 means the file is not a spec-conformant modern DXF. The
HEADER is then peeked for $ACADVER/$DWGCODEPAGE: pre-2007 drawings
with a declared code page decode through it span-by-span (matching
AutoCAD, without materializing one giant string), while R2007+ or
headerless files fall back to UTF-8 (replacement chars mark the
broken bytes).
Binary path: when options.encoding is omitted, the HEADER is peeked for
a pre-2007 $DWGCODEPAGE and that code page is used for null-terminated
string values (same AutoCAD rule as ASCII). R2007+ / missing header keep
UTF-8.
Create a pair reader from DXF bytes (ASCII or binary).
ASCII path encoding strategy (hybrid of byte-trust and header sniffing):
options.encodingalways wins — the caller asserts the encoding, no sniffing contradicts it. Non-UTF-8 overrides decode line-by-line (never a single full-file string).$DWGCODEPAGE, so the header is never consulted — modern files skip the header pre-scan entirely and stream straight from bytes.$ACADVER/$DWGCODEPAGE: pre-2007 drawings with a declared code page decode through it span-by-span (matching AutoCAD, without materializing one giant string), while R2007+ or headerless files fall back to UTF-8 (replacement chars mark the broken bytes).Binary path: when
options.encodingis omitted, the HEADER is peeked for a pre-2007$DWGCODEPAGEand that code page is used for null-terminated string values (same AutoCAD rule as ASCII). R2007+ / missing header keep UTF-8.