Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write: pad certain VRs with spaces instead of null bytes #81

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion write/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,14 @@ func Element(e *dicomio.Encoder, elem *element.Element, opts ...Option) {
}
sube.WriteString(s)
if len(s)%2 == 1 {
sube.WriteByte(0)
switch vr {
// Values with VRs constructed of character strings, except in the case of the VR UI, shall be padded with SPACE characters
// per http://dicom.nema.org/medical/dicom/current/output/html/part05.html#sect_6.2
case "DT", "LO", "LT", "PN", "SH", "ST", "UT":
sube.WriteString(" ")
default:
sube.WriteByte(0)
}
}
}
if sube.Error() != nil {
Expand Down