add support for overriding 'isEncapsulated()' - #60
Open
keean wants to merge 1 commit into
Open
Conversation
MichaelLeeHobbs
referenced
this pull request
in MichaelLeeHobbs/dicomParser
Jul 23, 2026
…h encapsulation, charset decoding (#8) * feat: CP-246 defined-length UN sequences, speculative fallback, defined-length encapsulation Phase 2 backlog items 3 and 9. Defined-length sequence frames are now speculative: a parse failure inside rolls back only that element to an opaque value with a 'sequence-fallback' warning and parsing continues — this is the safe form of CP-246 (cornerstonejs#141: UN + defined length parses as an implicit sequence when vrLookup says SQ, binary fallback otherwise) and also recovers the cornerstonejs#114-class peek-misdetection derailment instead of erroring. TS-driven encapsulation detection (#59/#60): defined-length pixel data in a compressed transfer syntax whose value starts with an item tag is scanned as BOT+fragments (bounded scan, no delimiter required), with opaque-value fallback. parse() derives the compressed-TS flag from the transfer syntax UID. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ * feat: charset-aware string decoding (SpecificCharacterSet, ISO 2022) Phase 2 backlog item 4 (cornerstonejs#146). Ports the proven charset decoder from @ubercode/dcmtk (single-byte ISO_IR sets, UTF-8, GB18030/GBK, Shift_JIS, ISO 2022 escape walking for JP IR 13/87, KR IR 149, CN IR 58) with the PS3.5 Annex H/I/J fixture suite, adapted to typed errors and a Buffer-free build. parse() resolves (0008,0005) into a CharsetContext, walks the dataset tree iteratively (items inherit, own 0008,0005 overrides), and string()/text() decode through it — decode-then-split, so 0x5C trail bytes in multi-byte encodings never corrupt multi-value splitting. Unsupported charsets warn ('unsupported-charset') and decode as Latin-1; charset {assume, fallback} options cover headerless/misfiled data. UTF-8 mislabel detection helpers exported for consumers. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ --------- Co-authored-by: Claude Fable 5 <[email protected]>
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.
This adds
transferSyntaxtoByteStreamobject, so that it can be used byisEncapsulated. The logic inreadDicomElementExplicitis refactored so thatisEncapsulatedis used for the pixel-data, whereas the normal length criteria is used forUNand other element types.