Mercurial > hg > orthanc
changeset 1090:e494ceb8d763
support more encodings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Aug 2014 12:04:23 +0200 |
parents | 5ea0b56e850d |
children | a66224eec125 |
files | Core/Enumerations.cpp Core/Enumerations.h Core/Toolbox.cpp OrthancServer/FromDcmtkBridge.cpp OrthancServer/ParsedDicomFile.cpp OrthancServer/ParsedDicomFile.h Resources/Configuration.json Resources/EncodingTests.h Resources/EncodingTests.py UnitTestsSources/FromDcmtkTests.cpp UnitTestsSources/UnitTestsMain.cpp |
diffstat | 11 files changed, 367 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/Core/Enumerations.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -298,6 +298,15 @@ case Encoding_Hebrew: return "Hebrew"; + case Encoding_Thai: + return "Thai"; + + case Encoding_Japanese: + return "Japanese"; + + case Encoding_Chinese: + return "Chinese"; + default: throw OrthancException(ErrorCode_ParameterOutOfRange); } @@ -364,6 +373,21 @@ return Encoding_Hebrew; } + if (s == "THAI") + { + return Encoding_Thai; + } + + if (s == "JAPANESE") + { + return Encoding_Japanese; + } + + if (s == "CHINESE") + { + return Encoding_Chinese; + } + throw OrthancException(ErrorCode_ParameterOutOfRange); } @@ -430,4 +454,99 @@ throw OrthancException(ErrorCode_ParameterOutOfRange); } } + + + bool GetDicomEncoding(Encoding& encoding, + const char* specificCharacterSet) + { + std::string s = specificCharacterSet; + Toolbox::ToUpperCase(s); + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ + // https://github.com/dcm4che/dcm4che/blob/master/dcm4che-core/src/main/java/org/dcm4che3/data/SpecificCharacterSet.java + if (s == "ISO_IR 6" || + s == "ISO_IR 192" || + s == "ISO 2022 IR 6") + { + encoding = Encoding_Utf8; + } + else if (s == "ISO_IR 100" || + s == "ISO 2022 IR 100") + { + encoding = Encoding_Latin1; + } + else if (s == "ISO_IR 101" || + s == "ISO 2022 IR 101") + { + encoding = Encoding_Latin2; + } + else if (s == "ISO_IR 109" || + s == "ISO 2022 IR 109") + { + encoding = Encoding_Latin3; + } + else if (s == "ISO_IR 110" || + s == "ISO 2022 IR 110") + { + encoding = Encoding_Latin4; + } + else if (s == "ISO_IR 148" || + s == "ISO 2022 IR 148") + { + encoding = Encoding_Latin5; + } + else if (s == "ISO_IR 144" || + s == "ISO 2022 IR 144") + { + encoding = Encoding_Cyrillic; + } + else if (s == "ISO_IR 127" || + s == "ISO 2022 IR 127") + { + encoding = Encoding_Arabic; + } + else if (s == "ISO_IR 126" || + s == "ISO 2022 IR 126") + { + encoding = Encoding_Greek; + } + else if (s == "ISO_IR 138" || + s == "ISO 2022 IR 138") + { + encoding = Encoding_Hebrew; + } + else if (s == "ISO_IR 166" || s == "ISO 2022 IR 166") + { + encoding = Encoding_Thai; + } + else if (s == "ISO_IR 13" || s == "ISO 2022 IR 13") + { + encoding = Encoding_Japanese; + } + else if (s == "GB18030") + { + encoding = Encoding_Chinese; + } + /* + else if (s == "ISO 2022 IR 149") + { + TODO + } + else if (s == "ISO 2022 IR 159") + { + TODO + } + else if (s == "ISO 2022 IR 87") + { + TODO + } + */ + else + { + return false; + } + + // The encoding was properly detected + return true; + } }
--- a/Core/Enumerations.h Tue Aug 05 08:49:25 2014 +0200 +++ b/Core/Enumerations.h Tue Aug 05 12:04:23 2014 +0200 @@ -230,6 +230,7 @@ }; + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ enum Encoding { Encoding_Ascii, @@ -238,11 +239,17 @@ Encoding_Latin2, Encoding_Latin3, Encoding_Latin4, - Encoding_Latin5, + Encoding_Latin5, // Turkish Encoding_Cyrillic, Encoding_Arabic, Encoding_Greek, - Encoding_Hebrew + Encoding_Hebrew, + Encoding_Thai, // TIS 620-2533 + Encoding_Japanese, // JIS X 0201 (Shift JIS): Katakana + Encoding_Chinese // GB18030 - Chinese simplified + //Encoding_JapaneseKanji, // Multibyte - JIS X 0208: Kanji + //Encoding_JapaneseSupplementaryKanji, // Multibyte - JIS X 0212: Supplementary Kanji set + //Encoding_Korean, // Multibyte - KS X 1001: Hangul and Hanja }; @@ -294,4 +301,7 @@ ImageFormat StringToImageFormat(const char* format); unsigned int GetBytesPerPixel(PixelFormat format); + + bool GetDicomEncoding(Encoding& encoding, + const char* specificCharacterSet); }
--- a/Core/Toolbox.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/Core/Toolbox.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -532,6 +532,8 @@ { const char* encoding; + + // http://bradleyross.users.sourceforge.net/docs/dicom/doc/src-html/org/dcm4che2/data/SpecificCharacterSet.html switch (sourceEncoding) { case Encoding_Utf8: @@ -576,6 +578,18 @@ case Encoding_Hebrew: encoding = "ISO-8859-8"; break; + + case Encoding_Japanese: + encoding = "SHIFT-JIS"; + break; + + case Encoding_Chinese: + encoding = "GB18030"; + break; + + case Encoding_Thai: + encoding = "TIS620.2533-0"; + break; default: throw OrthancException(ErrorCode_NotImplemented);
--- a/OrthancServer/FromDcmtkBridge.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/OrthancServer/FromDcmtkBridge.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -128,56 +128,26 @@ if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good()) { std::string characterSet = Toolbox::StripSpaces(std::string(tmp.c_str())); - Toolbox::ToUpperCase(characterSet); - if (characterSet == "ISO_IR 6" || - characterSet == "ISO_IR 192") - { - encoding = Encoding_Utf8; - } - else if (characterSet == "ISO_IR 100") + if (characterSet.empty()) { - encoding = Encoding_Latin1; - } - else if (characterSet == "ISO_IR 101") - { - encoding = Encoding_Latin2; - } - else if (characterSet == "ISO_IR 109") - { - encoding = Encoding_Latin3; - } - else if (characterSet == "ISO_IR 110") - { - encoding = Encoding_Latin4; + // Empty specific character set tag: Use the default encoding } - else if (characterSet == "ISO_IR 148") - { - encoding = Encoding_Latin5; - } - else if (characterSet == "ISO_IR 144") + else if (GetDicomEncoding(encoding, characterSet.c_str())) { - encoding = Encoding_Cyrillic; - } - else if (characterSet == "ISO_IR 127") - { - encoding = Encoding_Arabic; + // The specific character set is supported by the Orthanc core } - else if (characterSet == "ISO_IR 126") - { - encoding = Encoding_Greek; - } - else if (characterSet == "ISO_IR 138") + else { - encoding = Encoding_Hebrew; - } - else if (!characterSet.empty()) - { - LOG(WARNING) << "Value of Specific Character Set (0008,0005) is not supported: " << characterSet; - // Fallback to ASCII (remove all special characters) + LOG(WARNING) << "Value of Specific Character Set (0008,0005) is not supported: " << characterSet + << ", fallback to ASCII (remove all special characters)"; encoding = Encoding_Ascii; } } + else + { + // No specific character set tag: Use the default encoding + } return encoding; }
--- a/OrthancServer/ParsedDicomFile.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -1215,4 +1215,71 @@ { return pimpl_->encoding_; } + + + void ParsedDicomFile::SetEncoding(Encoding encoding) + { + std::string s; + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ + switch (encoding) + { + case Encoding_Utf8: + case Encoding_Ascii: + s = "ISO_IR 192"; + break; + + case Encoding_Latin1: + s = "ISO_IR 100"; + break; + + case Encoding_Latin2: + s = "ISO_IR 101"; + break; + + case Encoding_Latin3: + s = "ISO_IR 109"; + break; + + case Encoding_Latin4: + s = "ISO_IR 110"; + break; + + case Encoding_Latin5: + s = "ISO_IR 148"; + break; + + case Encoding_Cyrillic: + s = "ISO_IR 144"; + break; + + case Encoding_Arabic: + s = "ISO_IR 127"; + break; + + case Encoding_Greek: + s = "ISO_IR 126"; + break; + + case Encoding_Hebrew: + s = "ISO_IR 138"; + break; + + /* + case Encoding_Japanese: + s = "ISO_IR 13"; + break; + */ + + case Encoding_Thai: + s = "ISO_IR 166"; + break; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + Replace(DICOM_TAG_SPECIFIC_CHARACTER_SET, "", DicomReplaceMode_InsertIfAbsent); + } + }
--- a/OrthancServer/ParsedDicomFile.h Tue Aug 05 08:49:25 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.h Tue Aug 05 12:04:23 2014 +0200 @@ -116,6 +116,8 @@ ImageExtractionMode mode); Encoding GetEncoding() const; + + void SetEncoding(Encoding encoding); }; }
--- a/Resources/Configuration.json Tue Aug 05 08:49:25 2014 +0200 +++ b/Resources/Configuration.json Tue Aug 05 12:04:23 2014 +0200 @@ -183,7 +183,9 @@ "LimitJobs" : 10, // The default encoding that is assumed for DICOM files without - // "SpecificCharacterSet" DICOM tag. The allowed values are - // currently "Latin1", "Utf8" and "Ascii". + // "SpecificCharacterSet" DICOM tag. The allowed values are "Ascii", + // "Utf8", "Latin1", "Latin2", "Latin3", "Latin4", "Latin5", + // "Cyrillic", "Arabic", "Greek", "Hebrew", "Thai", "Japanese", + // and "Chinese". "DefaultEncoding" : "Latin1" }
--- a/Resources/EncodingTests.h Tue Aug 05 08:49:25 2014 +0200 +++ b/Resources/EncodingTests.h Tue Aug 05 12:04:23 2014 +0200 @@ -1,40 +1,49 @@ -static const unsigned int testEncodingsCount = 11; -static const Orthanc::Encoding testEncodings[] = { - Orthanc::Encoding_Latin5, - Orthanc::Encoding_Hebrew, - Orthanc::Encoding_Greek, - Orthanc::Encoding_Arabic, - Orthanc::Encoding_Cyrillic, - Orthanc::Encoding_Latin4, - Orthanc::Encoding_Latin3, - Orthanc::Encoding_Latin2, - Orthanc::Encoding_Latin1, - Orthanc::Encoding_Utf8, - Orthanc::Encoding_Ascii +static const unsigned int testEncodingsCount = 14; +static const ::Orthanc::Encoding testEncodings[] = { + ::Orthanc::Encoding_Latin5, + ::Orthanc::Encoding_Hebrew, + ::Orthanc::Encoding_Greek, + ::Orthanc::Encoding_Arabic, + ::Orthanc::Encoding_Cyrillic, + ::Orthanc::Encoding_Latin4, + ::Orthanc::Encoding_Latin3, + ::Orthanc::Encoding_Latin2, + ::Orthanc::Encoding_Latin1, + ::Orthanc::Encoding_Utf8, + ::Orthanc::Encoding_Thai, + ::Orthanc::Encoding_Japanese, + ::Orthanc::Encoding_Ascii, + ::Orthanc::Encoding_Chinese }; -static const char *testEncodingsEncoded[11] = { - "\xe9\xe4\xf6\xf2\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\xe3\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\xc8\x3f\x3f\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\xd5\x3f\x3f", - "\x3f\x3f\x3f\x3f\xb4\x3f\x3f\x3f\x3f\x3f\xfb", - "\xe9\xe4\xf6\x3f\x3f\x3f\x3f\x3f\x3f\xf3\x3f", - "\xe9\xe4\xf6\xf2\x3f\x3f\xf8\x3f\x3f\x3f\x3f", - "\xe9\xe4\xf6\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\xe9\xe4\xf6\xf2\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f" +static const char *testEncodingsEncoded[14] = { + "\xe9\xe4\xf6\xf2\xdd", + "\xe3", + "\xc8", + "\xd5", + "\xb4\xfb", + "\xe9\xe4\xf6\xf3", + "\xe9\xe4\xf6\xf2\xf8\xa9", + "\xe9\xe4\xf6", + "\xe9\xe4\xf6\xf2", + "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b\xe0\xb9\x9b\xef\xbe\x88\xc4\xb0", + "\xfb", + "\x84\x44\x83\xa6\xc8", + "", + "\x81\x30\x89\x37\x81\x30\x89\x38\xA8\xA4\xA8\xA2\x81\x30\x89\x39\x81\x30\x8A\x30" }; -static const char *testEncodingsExpected[11] = { - "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\xd7\x93\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\xce\x98\x3f\x3f\x3f\x3f\x3f", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\xd8\xb5\x3f\x3f", - "\x3f\x3f\x3f\x3f\xd0\x94\x3f\x3f\x3f\x3f\x3f\xd1\x9b", - "\xc3\xa9\xc3\xa4\xc3\xb6\x3f\x3f\x3f\x3f\x3f\x3f\xc4\xb7\x3f", - "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\x3f\x3f\xc4\x9d\x3f\x3f\x3f\x3f", - "\xc3\xa9\xc3\xa4\xc3\xb6\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\x3f\x3f\x3f\x3f\x3f\x3f\x3f", - "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b", - "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f" +static const char *testEncodingsExpected[14] = { + "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xc4\xb0", + "\xd7\x93", + "\xce\x98", + "\xd8\xb5", + "\xd0\x94\xd1\x9b", + "\xc3\xa9\xc3\xa4\xc3\xb6\xc4\xb7", + "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xc4\x9d\xc4\xb0", + "\xc3\xa9\xc3\xa4\xc3\xb6", + "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2", + "\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b\xe0\xb9\x9b\xef\xbe\x88\xc4\xb0", + "\xe0\xb9\x9b", + "\xd0\x94\xce\x98\xef\xbe\x88", + "", + "\xc3\x9e\xc3\x9f\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3" };
--- a/Resources/EncodingTests.py Tue Aug 05 08:49:25 2014 +0200 +++ b/Resources/EncodingTests.py Tue Aug 05 12:04:23 2014 +0200 @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -source = u'éäöòДΘĝדصķћ' +source = u'éäöòДΘĝדصķћ๛ネİ' encodings = { 'UTF-8' : 'Utf8', @@ -15,8 +15,16 @@ 'ISO-8859-6' : 'Arabic', 'ISO-8859-7' : 'Greek', 'ISO-8859-8' : 'Hebrew', + 'TIS-620' : 'Thai', + 'SHIFT-JIS' : 'Japanese', + #'GB18030' : 'Chinese', } +#from encodings.aliases import aliases +#for a, b in aliases.iteritems(): +# print '%s : %s' % (a, b) + + # "63" corresponds to "?" l = [] encoded = [] @@ -30,12 +38,24 @@ for encoding, orthancEnumeration in encodings.iteritems(): - l.append('Orthanc::Encoding_%s' % orthancEnumeration) - s = source.encode(encoding, 'replace') + l.append('::Orthanc::Encoding_%s' % orthancEnumeration) + s = source.encode(encoding, 'ignore') encoded.append(ToArray(s)) expected.append(ToArray(s.decode(encoding).encode('utf-8'))) -print 'static const unsigned int testEncodingsCount = %d;' % len(encodings) -print 'static const Orthanc::Encoding testEncodings[] = {\n %s\n};' % (',\n '.join(l)) -print 'static const char *testEncodingsEncoded[%d] = {\n %s\n};' % (len(encodings), ',\n '.join(encoded)) -print 'static const char *testEncodingsExpected[%d] = {\n %s\n};' % (len(encodings), ',\n '.join(expected)) + +# https://en.wikipedia.org/wiki/GB_18030#Technical_details +l.append('::Orthanc::Encoding_Chinese') +expected.append(ToArray('Þßàáâã')) +encoded.append('"\\x81\\x30\\x89\\x37\\x81\\x30\\x89\\x38\\xA8\\xA4\\xA8\\xA2\\x81\\x30\\x89\\x39\\x81\\x30\\x8A\\x30"') + + +if True: + print 'static const unsigned int testEncodingsCount = %d;' % len(l) + print 'static const ::Orthanc::Encoding testEncodings[] = {\n %s\n};' % (',\n '.join(l)) + print 'static const char *testEncodingsEncoded[%d] = {\n %s\n};' % (len(l), ',\n '.join(encoded)) + print 'static const char *testEncodingsExpected[%d] = {\n %s\n};' % (len(l), ',\n '.join(expected)) +else: + for i in range(len(expected)): + print expected[i] + #print '%s: %s' % (expected[i], l[i])
--- a/UnitTestsSources/FromDcmtkTests.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/UnitTestsSources/FromDcmtkTests.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -179,7 +179,7 @@ } -TEST(Toolbox, Encodings1) +TEST(FromDcmtkBridge, Encodings1) { for (unsigned int i = 0; i < testEncodingsCount; i++) { @@ -190,3 +190,64 @@ EXPECT_EQ(expected, s); } } + + +TEST(FromDcmtkBridge, Enumerations) +{ + Encoding e; + + ASSERT_FALSE(GetDicomEncoding(e, "")); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 6")); ASSERT_EQ(Encoding_Utf8, e); + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-2 + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 100")); ASSERT_EQ(Encoding_Latin1, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 101")); ASSERT_EQ(Encoding_Latin2, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 109")); ASSERT_EQ(Encoding_Latin3, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 110")); ASSERT_EQ(Encoding_Latin4, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 144")); ASSERT_EQ(Encoding_Cyrillic, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 127")); ASSERT_EQ(Encoding_Arabic, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 126")); ASSERT_EQ(Encoding_Greek, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 138")); ASSERT_EQ(Encoding_Hebrew, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 148")); ASSERT_EQ(Encoding_Latin5, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 13")); ASSERT_EQ(Encoding_Japanese, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 166")); ASSERT_EQ(Encoding_Thai, e); + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-3 + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 6")); ASSERT_EQ(Encoding_Utf8, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 100")); ASSERT_EQ(Encoding_Latin1, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 101")); ASSERT_EQ(Encoding_Latin2, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 109")); ASSERT_EQ(Encoding_Latin3, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 110")); ASSERT_EQ(Encoding_Latin4, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 144")); ASSERT_EQ(Encoding_Cyrillic, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 127")); ASSERT_EQ(Encoding_Arabic, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 126")); ASSERT_EQ(Encoding_Greek, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 138")); ASSERT_EQ(Encoding_Hebrew, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 148")); ASSERT_EQ(Encoding_Latin5, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 13")); ASSERT_EQ(Encoding_Japanese, e); + ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 166")); ASSERT_EQ(Encoding_Thai, e); + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-4 + ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 87")); //ASSERT_EQ(Encoding_JapaneseKanji, e); + ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 159")); //ASSERT_EQ(Encoding_JapaneseKanjiSupplementary, e); + ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 149")); //ASSERT_EQ(Encoding_Korean, e); + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-5 + ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 192")); ASSERT_EQ(Encoding_Utf8, e); + ASSERT_TRUE(GetDicomEncoding(e, "GB18030")); ASSERT_EQ(Encoding_Chinese, e); +} + + +TEST(FromDcmtkBridge, DISABLED_Encodings3) +{ + for (unsigned int i = 0; i < testEncodingsCount; i++) + { + ParsedDicomFile f; + f.SetEncoding(testEncodings[i]); + + std::string source(testEncodingsEncoded[i]); + std::string expected(testEncodingsExpected[i]); + std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i]); + std::cout << EnumerationToString(testEncodings[i]) << std::endl; + EXPECT_EQ(expected, s); + } +}
--- a/UnitTestsSources/UnitTestsMain.cpp Tue Aug 05 08:49:25 2014 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Tue Aug 05 12:04:23 2014 +0200 @@ -652,6 +652,9 @@ ASSERT_EQ(Encoding_Arabic, StringToEncoding(EnumerationToString(Encoding_Arabic))); ASSERT_EQ(Encoding_Greek, StringToEncoding(EnumerationToString(Encoding_Greek))); ASSERT_EQ(Encoding_Hebrew, StringToEncoding(EnumerationToString(Encoding_Hebrew))); + ASSERT_EQ(Encoding_Japanese, StringToEncoding(EnumerationToString(Encoding_Japanese))); + ASSERT_EQ(Encoding_Chinese, StringToEncoding(EnumerationToString(Encoding_Chinese))); + ASSERT_EQ(Encoding_Thai, StringToEncoding(EnumerationToString(Encoding_Thai))); ASSERT_EQ(ResourceType_Patient, StringToResourceType(EnumerationToString(ResourceType_Patient))); ASSERT_EQ(ResourceType_Study, StringToResourceType(EnumerationToString(ResourceType_Study)));