1
votes

Sorry for I am not good at DICOM. I was trying to write into DICOM tag (0008,0080) with Chinese words by fo-dicom. But found the Tag value just show the messy code in the result file. Please help to review it .

The C# code is below:

var file = DicomFile.Open(@"C:\Users\Administrator\Desktop\20D08F04"); 

//file.Dataset.Add(DicomTag.SpecificCharacterSet, "GB18030");
//file.Dataset.Add(DicomTag.SpecificCharacterSet, "ISO_IR 192");
//I already tried to specified the 0008,0005 with GBK and Utf-8. but it doesn't work. 
file.Dataset.Add(DicomTag.InstitutionName, "测试");

file.Save(@"C:\Users\Administrator\Desktop\test123.dcm");

The resulting file looks like blew in the DCMTK editor.

May anyone of you can help me?

Thanks in advance

Joe

enter image description here

Updated

I am sure the DVTK Dicom file editor support the Chinese character set. Because there is another attribute Patient's Name's value is Chinese. And can be viewed properly. Thanks.

enter image description here

1
Does the viewer support the character set? It doesn't mean tha the name was not set correctly if the viewer tool can't display it. Read it with your own code and see if it returns correctly. You may have to set the Specific Character Set (0008,0005) tag as well.john elemans
@johnelemans Please review my updated. Thanks.Joe.wang

1 Answers

3
votes

The default encoding in .NET fo-dicom is US-ASCII. It does not help if you set the Specific Character Set after you have opened the DICOM file, parsing is done in the open operation. Specific Character Set only applies if it already set in the DICOM file.

What you can do is to set the "fallback encoding" to be used if Specific Character Set is not specified in the DICOM file, in the argument list of DicomFile.Open.

Try this for example:

var file = DicomFile.Open(fileName, DicomEncoding.GetEncoding("GB18030"));

And as @johnelemans pointed out in the comments, also verify that your viewer is capable of displaying the Chinese character set.