Decoding the control character sets

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Vargeeshj
Posts: 7
Joined: Wed, 2016-03-09, 13:20

Decoding the control character sets

#1 Post by Vargeeshj »

we have problem in decoding the control character sets.

Below is the encoded sample with the Japanese control characters
Suzuki^Hiroshi=$BNkLZ(B^$B9((B=$B$9$:$-(B^$B$R$m$7(B
Need to decode the above string with equivalent Japanese characters.


Please suggest the solution.

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

Re: Decoding the control character sets

#2 Post by J. Riesmeier »

What do you mean by "have a problem in decoding"?
What did you try and what did not work...?

Vargeeshj
Posts: 7
Joined: Wed, 2016-03-09, 13:20

Re: Decoding the control character sets

#3 Post by Vargeeshj »

Thanks for your reply. we have fixed the issue as shown below.

wstring Decode(string strIdentifierText)
{
DcmSpecificCharacterSet converter;
OFString strEncoded;
wstring decoded;
OFCondition cond = converter.selectCharacterSet("\\ISO 2022 IR 87");
if (cond.good())
{
cond = converter.convertString(strIdentifierText.c_str(), strEncoded);
int wchars_num = MultiByteToWideChar(CP_UTF8 , 0 ,strEncoded.c_str(), -1, NULL , 0 );
wchar_t *wstrDecoded = new wchar_t[wchars_num];
MultiByteToWideChar(CP_UTF8 , 0 , strEncoded.c_str() , -1, wstrDecoded , wchars_num );
decoded = wstrDecoded;
delete[] wstrDecoded;
}
return decoded;
}

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

Re: Decoding the control character sets

#4 Post by J. Riesmeier »

Instead of calling MultiByteToWideChar(), i.e. the Windows API function, directly, you could also use OFCharacterEncoding::convertToWideCharString() from DCMTK's ofstd module.

Post Reply

Who is online

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