Although the spec is designed to allow trailing spaces, it is most likely useless in practice. I have tested with tools and libs, none of them provide the dicom tag value as is.
The trailing spaces can be removed by default, or by providing an optional flag to allow it.