From 522d3ec29ebea7fc070faa9f36086d3e36d5e45e Mon Sep 17 00:00:00 2001 From: Selim Youssry Date: Thu, 28 May 2020 19:54:42 +0200 Subject: [PATCH] [ISSUE-80] Values with VRs constructed of character strings are padded with trailing NULL instead of spaces - per http://dicom.nema.org/medical/dicom/current/output/html/part05.html#sect_6.2 --- write/writer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/write/writer.go b/write/writer.go index d4fe85ae..3b4ebb1a 100644 --- a/write/writer.go +++ b/write/writer.go @@ -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 {