dcmodify vs. "ISO_IR 192" character set

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ilariari
Posts: 16
Joined: Fri, 2018-01-12, 12:21

dcmodify vs. "ISO_IR 192" character set

#1 Post by ilariari »

Hallo!
I'm dealing with a dicom file whose TAG (0008, 0005) holds "ISO_IR 192" (Utf-8).
Such file contains non ASCII characters, i.e. "à", "è", "ì": the dump produced from dcmdump.exe (v.3.6.2) gets a correct representation of those characters.

Now, i'm trying to use dcmodify tool (v.3.6.2) to modify TAG (0010, 0010) in order to insert in the corresponding Value "Niccolò".
The command line I use is: dcmodify -v -i "(0x0010, 0x0010)=Niccolò" IMAGES/0000.dcm
The result is incorrect, as character "ò" is encoded 0x28A6 instead of 0xc3b2 (U+00F2 - ò - LATIN SMALL LETTER O WITH GRAVE).
dcmdump confirms the introduction of wrong characters.

Is there a solution to this issue?

Thank you for any help, very appreciated!
Ilaria

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmodify vs. "ISO_IR 192" character set

#2 Post by J. Riesmeier »

Maybe, the character set (aka codepage) of your shell (cmd.exe?) is not set appropriately. Did you check dcmdump's output on the console or in a text editor (which supports UTF-8)?

ilariari
Posts: 16
Joined: Fri, 2018-01-12, 12:21

Re: dcmodify vs. "ISO_IR 192" character set

#3 Post by ilariari »

I'll check on the base of your hint, thank you in advance!

Best regards
Ilaria

ilariari
Posts: 16
Joined: Fri, 2018-01-12, 12:21

Re: dcmodify vs. "ISO_IR 192" character set

#4 Post by ilariari »

Hallo, after having checked my environment, I solved my issue by adding th following line code to my app:

QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

In fact, I'm developping in the Qt framework and the problem was lying in the arguments list parsing performed by the QProcess class.

Hope, it could be useful for someone else.

Thank you and best regards.
Ilaria

frank83
Posts: 5
Joined: Thu, 2021-11-11, 09:32

Re: dcmodify vs. "ISO_IR 192" character set

#5 Post by frank83 »

Hello everybody,

I have a similar issue while using dcmodify with umlaut chars, like this:

Code: Select all

dcmodify -v -nb  -i "(0x0010, 0x2297)=Rossi^Märio" 0000.dcm
This call seems to generate a wrong dicom file even if the starting dicom has the right charset "ISO_IR 192" (Utf-8).
Any hints on how to use the dcmodify with umlaut chars are welcome.
J. Riesmeier wrote: Fri, 2018-01-12, 19:14 Maybe, the character set (aka codepage) of your shell (cmd.exe?) is not set appropriately. Did you check dcmdump's output on the console or in a text editor (which supports UTF-8)?
Tried also using a batch file to change the charset of cmd.exe with "chcp 65001" right before calling dcmodify, but it doesn't seem to work ...

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmodify vs. "ISO_IR 192" character set

#6 Post by J. Riesmeier »

You could also try with "-if file.txt", where file.txt contains the UTF-8 encoded string of characters.
By the way, there is no need to prefix the hex numbers with "0x".

In my bash (Linux shell), it works out of the box since the local encoding is set to UTF-8. Windows is always something special...

frank83
Posts: 5
Joined: Thu, 2021-11-11, 09:32

Re: dcmodify vs. "ISO_IR 192" character set

#7 Post by frank83 »

J. Riesmeier wrote: Thu, 2021-11-11, 18:19 You could also try with "-if file.txt", where file.txt contains the UTF-8 encoded string of characters.
Thank you so much for the prompt reply, I tried the following:

Code: Select all

dcmodify -v -nb -if "(0010, 2297)"=file.txt 0000.dcm
and it works! But I have a question: is there a more efficient way to insert all modified tags in just one single file?

ps. we'll think about switching to Linux sooner or later: D

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmodify vs. "ISO_IR 192" character set

#8 Post by J. Riesmeier »

You could e.g. create a so-called command file that contains all modifications, e.g. a "modify.txt" with the following contents (encoded as UTF-8):

Code: Select all

-i SpecificCharacterSet="ISO_IR 192"
-m PatientName="Riesmeier^Jörg"
-m PatientID=0815
-i PatientComments="Some Comment"
...
And then call "dcmodify -v -nb @modify.txt 0000.dcm". You could also create multiple command files and then call dcmodify with multiple @<filename> arguments. This feature is documented in the manpages of the DCMTK tools.

frank83
Posts: 5
Joined: Thu, 2021-11-11, 09:32

Re: dcmodify vs. "ISO_IR 192" character set

#9 Post by frank83 »

Thank you so much!

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest