Skip to content

Commit

Permalink
write: pad certain VRs with spaces instead of null bytes (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Selim Youssry <selim@ferrumhealth.com>
  • Loading branch information
2 people authored and suyashkumar committed May 30, 2020
1 parent 5b38ce7 commit 2daf5f9
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 2daf5f9

Please sign in to comment.