dcmjs icon indicating copy to clipboard operation
dcmjs copied to clipboard

Text encoding, how to do it?

Open vsaase opened this issue 6 years ago • 2 comments

Hi, thanks for the library. I am having problems with string encodings, see this example:

var dcmjs = require("dcmjs");
const { DicomDict, DicomMessage} = dcmjs.data;
var ds = new DicomDict({})
ds.upsertTag("0008103E", "LO", "ä")
buf = ds.write()
ds2 = DicomMessage.readFile(buf)
ds2.dict["0008103E"].Value[0] == 'ä'

What is the right way to write DICOM files with proper encoding? Reading DICOM files containing special characters which were created with pydicom (without explicitly specifying the character set) works well in my case.

vsaase avatar Feb 23 '20 18:02 vsaase

I think the problem is here, strings are read byte by byte, which is not compatible with utf8: https://github.com/dcmjs-org/dcmjs/blob/168a95401f1eac262a8488dd0d9be4a5482a83f0/src/BufferStream.js#L214-L225

vsaase avatar Feb 23 '20 18:02 vsaase

fixed for my use-case with #92

vsaase avatar Feb 23 '20 20:02 vsaase