Skip to content

fix(VR): only remove trailing spaces from LT, ST, UT, UC and TM values - #617

Open
wleeaf wants to merge 1 commit into
dcmjs-org:0.xfrom
wleeaf:text-trailing-control-chars
Open

wleeaf wants to merge 1 commit into
dcmjs-org:0.xfrom
wleeaf:text-trailing-control-chars

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown

rtrim() in ValueRepresentation.js uses /\s*$/. That removes every trailing whitespace character from Value: spaces, but also CR, LF, FF, tabs, NBSP and the ideographic space. For LT, ST, UT, UC and TM, PS3.5 Table 6.2-1 only allows padding with trailing spaces. CR, LF and FF are part of the text, and the Specific Character Set can include other whitespace characters.

An example: test-SR.dcm from the pydicom test files has a TextValue (0040,A160) of Sample Text\rA\nB\r\nC\n\r. dcmjs returns Sample Text\rA\nB\r\nC, while DCMTK's dcm2json keeps the whole value. _rawValue was already right, so lossless round trips were not affected, only Value.

rtrim() now removes trailing spaces only.

A new "Individual VR comparisons" case in test/lossless-read-write.test.js covers a UT ending in CR LF plus a space. On master it fails, because the CR LF is removed from Value. The full jest suite passes (25 suites, 355 tests), and prettier and eslint are clean on the changed files.

rtrim() removed every trailing whitespace character, so a text value
ending in CR LF lost its line break in Value. Only spaces are padding for
these VRs (PS3.5 Table 6.2-1); CR, LF and FF are part of the text.
@netlify

netlify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit 998d472
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6ade6d0afd7cc1d6adca4e64
😎 Deploy Preview https://deploy-preview-617--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant