Unicode conversion

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Unicode conversion

#1 Post by Soumya Basheer »

Hi,
How we can read a japanese/chinese patient name from dcmdataset and save it to database as unicode?

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

Re: Unicode conversion

#2 Post by J. Riesmeier »

If DCMTK is compiled with character set conversion enabled (requires one of the supported conversion libraries), you could simply call convertToUTF8() on the DcmDataset instance.

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#3 Post by Soumya Basheer »

Thank you.
I want to query a japanese patient name from db, so I need to get that patient name in japanese. could you please explain how I can acheive that? As dcmtk supports only multibyte option in properties whether I can acheive that?

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

Re: Unicode conversion

#4 Post by J. Riesmeier »

Could you please provide more details on your use case? DCMTK supports all Specific Character Sets that are defined by the DICOM standard, at least for input. With "query a japanese patient name from db" you mean what?

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#5 Post by Soumya Basheer »

I have a database. I have saved a japanese name in database. When a C-FIND command comes i have to extract a japanese patient name from Dcmdataset and convert that to unicode. Then I have to compare that name with the name saved in database..How I can extract the patient name to unicode?Could you please help me for it.

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

Re: Unicode conversion

#6 Post by J. Riesmeier »

As I said, you can use DcmDataset::convertToUTF8() to convert the entire DICOM dataset of the C-FIND request from any character set that is defined by the DICOM standard (e.g. Japanese) to Unicode (UTF-8). After this conversion, you can access the Patient's Name (0010,0010), which is now encoded in UTF-8, using e.g. DcmDataset::findAndGetOFString(). This should answer your question "How I can extract the patient name to unicode?".

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#7 Post by Soumya Basheer »

Thank you. I could do it and could see it in japanes after converting that to widechar.

One thing that I am facing is I am not getting DCMTK_ENABLE_CHARSET_CONVERSION preprocessor eventhough I have enabled it with ICU in cmake.
For checking I gave this preprocessor in ofstd and done my experimentation. Could you please tell me whether I need to do anything more for enabling DCMTK_ENABLE_CHARSET_CONVERSION preprocessor.

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

Re: Unicode conversion

#8 Post by J. Riesmeier »

And what is the value of DCMTK_ENABLE_CHARSET_CONVERSION after CMake performed the configure step? Is the CMake variable DCMTK_WITH_ICU set to "ON"?

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#9 Post by Soumya Basheer »

DCMTK_ENABLE_CHARSET_CONVERSION value is ICU. DCMTK_WITH_ICU is set to on,but it is not working in ofchrenc.cc and while calling the convertToUTF8() I am getting error as "No character encoding library available". But After giving the preprocessor DCMTK_ENABLE_CHARSET_CONVERSION in ofstd project manually and adding the icu libs to ofstd project properties everything works well.

I have the below log in cmake

Selecting Windows SDK version 10.0.10240.0 to target Windows 10.0.14393.
Info: DCMTK OPENSSL support will be enabled
Info: DCMTK ICONV support will be enabled
Info: DCMTK ICU support will be enabled
Info: DCMTK will compile with built-in (compiled-in) dictionary
Info: DCMTK will not try to load external dictionary from default path on startup
Info: DCMTK's builtin private dictionary support will be disabled
Info: Thread support will be enabled
Info: Wide char file I/O functions will be enabled
Info: Wide char main function for command line tools will be enabled
Info: Building DCMTK with character set conversion support using the ICU
Info: Building DCMTK with large file support (LFS)
Info: C++11 features disabled
Info: STL vector support disabled
Info: STL algorithm support disabled
Info: STL limits support disabled
Info: STL list support disabled
Info: STL map support disabled
Info: STL memory support disabled
Info: STL stack support disabled
Info: STL string support disabled
Info: STL type_traits support disabled
Info: STL tuple support disabled
Info: STL system_error support disabled
Looking for CMake command CONFIGURE_PACKAGE_CONFIG_FILE
Looking for CMake command CONFIGURE_PACKAGE_CONFIG_FILE - found
Looking for CMake command WRITE_BASIC_PACKAGE_VERSION_FILE
Looking for CMake command WRITE_BASIC_PACKAGE_VERSION_FILE - found
Configuring done
Generating done

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

Re: Unicode conversion

#10 Post by J. Riesmeier »

When you compile DCMTK with ICU enabled, does dcmdump provide a --convert-to-utf8 option and does dcmdump --version show ICU as an "external libraries used"?

How did you integrate support for DCMTK into your own application?

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#11 Post by Soumya Basheer »

When you compile DCMTK with ICU enabled, does dcmdump provide a --convert-to-utf8 option and does dcmdump --version show ICU as an "external libraries used"?
Not showing the option and external library.

I am just doing an experimentation regarding the unicode characters. I am doing the below code in my app and linking corresponding libs and include files are added from dcmtk.
DcmFileFormat fileformat;
wchar_t* name = NULL;
OFString reqpatientName;

if (fileformat.loadFile("E:\\mod\\A00268283.dcm").good())
{
DcmDataset *dataset1 = fileformat.getDataset();
OFCondition status1 = dataset1->convertToUTF8();
dataset1->findAndGetOFString(DCM_PatientName, reqpatientName);
ConvMultiByteToWideChar(name, reqpatientName.c_str(), CP_UTF8, 0);
}

dcmdump --version gives as below

$dcmtk: dcmdump v3.6.3 2018-02-05 $

dcmdump: Dump DICOM file and data set

Host type: AMD64-Windows
Code page: 932 (OEM) / 932 (ANSI)

Compiled with DEBUG defined, i.e. with debug code

External libraries used: none

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

Re: Unicode conversion

#12 Post by J. Riesmeier »

Not showing the option and external library.
Then, ICU is not properly enabled. Maybe, you should re-build the DCMTK.

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#13 Post by Soumya Basheer »

Yes. I have checked by rebuilding also,but not getting.

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#14 Post by Soumya Basheer »

Which will be better to use ICU or ICONV. Which is supporting more languages?

Soumya Basheer
Posts: 17
Joined: Wed, 2018-07-11, 13:21

Re: Unicode conversion

#15 Post by Soumya Basheer »

Soumya Basheer wrote:Yes. I have checked by rebuilding also,but not getting.
I could do it using iconv not using icu..Thank you

Post Reply

Who is online

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