Unicode conversion
Moderator: Moderator Team
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Unicode conversion
Hi,
How we can read a japanese/chinese patient name from dcmdataset and save it to database as unicode?
How we can read a japanese/chinese patient name from dcmdataset and save it to database as unicode?
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
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.
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
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?
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?
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
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?
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
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.
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
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?".
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
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.
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.
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
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"?
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
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
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
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
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?
How did you integrate support for DCMTK into your own application?
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
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
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
-
- DCMTK Developer
- Posts: 2549
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unicode conversion
Then, ICU is not properly enabled. Maybe, you should re-build the DCMTK.Not showing the option and external library.
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
Yes. I have checked by rebuilding also,but not getting.
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
Which will be better to use ICU or ICONV. Which is supporting more languages?
-
- Posts: 17
- Joined: Wed, 2018-07-11, 13:21
Re: Unicode conversion
I could do it using iconv not using icu..Thank youSoumya Basheer wrote:Yes. I have checked by rebuilding also,but not getting.
Who is online
Users browsing this forum: No registered users and 1 guest