changeset 1087:e07b90fb00eb

more encodings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Aug 2014 18:12:21 +0200
parents e56c3ed8d738
children 6fd4434c1bcf
files Core/Enumerations.cpp Core/Enumerations.h Core/Toolbox.cpp OrthancServer/FromDcmtkBridge.cpp UnitTestsSources/UnitTestsMain.cpp
diffstat 5 files changed, 154 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Enumerations.cpp	Mon Aug 04 17:57:45 2014 +0200
+++ b/Core/Enumerations.cpp	Mon Aug 04 18:12:21 2014 +0200
@@ -265,14 +265,38 @@
   {
     switch (encoding)
     {
+      case Encoding_Ascii:
+        return "Ascii";
+
       case Encoding_Utf8:
         return "Utf8";
 
       case Encoding_Latin1:
         return "Latin1";
 
-      case Encoding_Ascii:
-        return "Ascii";
+      case Encoding_Latin2:
+        return "Latin2";
+
+      case Encoding_Latin3:
+        return "Latin3";
+
+      case Encoding_Latin4:
+        return "Latin4";
+
+      case Encoding_Latin5:
+        return "Latin5";
+
+      case Encoding_Cyrillic:
+        return "Cyrillic";
+
+      case Encoding_Arabic:
+        return "Arabic";
+
+      case Encoding_Greek:
+        return "Greek";
+
+      case Encoding_Hebrew:
+        return "Hebrew";
 
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
@@ -289,13 +313,55 @@
     {
       return Encoding_Utf8;
     }
-    else if (s == "LATIN1")
+
+    if (s == "ASCII")
+    {
+      return Encoding_Ascii;
+    }
+
+    if (s == "LATIN1")
     {
       return Encoding_Latin1;
     }
-    else if (s == "ASCII")
+
+    if (s == "LATIN2")
+    {
+      return Encoding_Latin2;
+    }
+
+    if (s == "LATIN3")
+    {
+      return Encoding_Latin3;
+    }
+
+    if (s == "LATIN4")
+    {
+      return Encoding_Latin4;
+    }
+
+    if (s == "LATIN5")
     {
-      return Encoding_Ascii;
+      return Encoding_Latin5;
+    }
+
+    if (s == "CYRILLIC")
+    {
+      return Encoding_Cyrillic;
+    }
+
+    if (s == "ARABIC")
+    {
+      return Encoding_Arabic;
+    }
+
+    if (s == "GREEK")
+    {
+      return Encoding_Greek;
+    }
+
+    if (s == "HEBREW")
+    {
+      return Encoding_Hebrew;
     }
 
     throw OrthancException(ErrorCode_ParameterOutOfRange);
--- a/Core/Enumerations.h	Mon Aug 04 17:57:45 2014 +0200
+++ b/Core/Enumerations.h	Mon Aug 04 18:12:21 2014 +0200
@@ -234,7 +234,15 @@
   {
     Encoding_Ascii,
     Encoding_Utf8,
-    Encoding_Latin1
+    Encoding_Latin1,
+    Encoding_Latin2,
+    Encoding_Latin3,
+    Encoding_Latin4,
+    Encoding_Latin5,
+    Encoding_Cyrillic,
+    Encoding_Arabic,
+    Encoding_Greek,
+    Encoding_Hebrew
   };
 
 
--- a/Core/Toolbox.cpp	Mon Aug 04 17:57:45 2014 +0200
+++ b/Core/Toolbox.cpp	Mon Aug 04 18:12:21 2014 +0200
@@ -539,12 +539,44 @@
         return source;
 
       case Encoding_Ascii:
-        return ConvertToAscii(source);;
+        return ConvertToAscii(source);
 
       case Encoding_Latin1:
         encoding = "ISO-8859-1";
         break;
 
+      case Encoding_Latin2:
+        encoding = "ISO-8859-2";
+        break;
+
+      case Encoding_Latin3:
+        encoding = "ISO-8859-3";
+        break;
+
+      case Encoding_Latin4:
+        encoding = "ISO-8859-4";
+        break;
+
+      case Encoding_Latin5:
+        encoding = "ISO-8859-9";
+        break;
+
+      case Encoding_Cyrillic:
+        encoding = "ISO-8859-5";
+        break;
+
+      case Encoding_Arabic:
+        encoding = "ISO-8859-6";
+        break;
+
+      case Encoding_Greek:
+        encoding = "ISO-8859-7";
+        break;
+
+      case Encoding_Hebrew:
+        encoding = "ISO-8859-8";
+        break;
+
       default:
         throw OrthancException(ErrorCode_NotImplemented);
     }
--- a/OrthancServer/FromDcmtkBridge.cpp	Mon Aug 04 17:57:45 2014 +0200
+++ b/OrthancServer/FromDcmtkBridge.cpp	Mon Aug 04 18:12:21 2014 +0200
@@ -128,8 +128,7 @@
     if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good())
     {
       std::string characterSet = Toolbox::StripSpaces(std::string(tmp.c_str()));
-
-      // TODO Add more encodings
+      Toolbox::ToUpperCase(characterSet);
 
       if (characterSet == "ISO_IR 6" ||
           characterSet == "ISO_IR 192")
@@ -140,6 +139,38 @@
       {
         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;
+      }
+      else if (characterSet == "ISO_IR 148")
+      {
+        encoding = Encoding_Latin5;
+      }
+      else if (characterSet == "ISO_IR 144")
+      {
+        encoding = Encoding_Cyrillic;
+      }
+      else if (characterSet == "ISO_IR 127")
+      {
+        encoding = Encoding_Arabic;
+      }
+      else if (characterSet == "ISO_IR 126")
+      {
+        encoding = Encoding_Greek;
+      }
+      else if (characterSet == "ISO_IR 138")
+      {
+        encoding = Encoding_Hebrew;
+      }
       else if (!characterSet.empty())
       {
         LOG(WARNING) << "Value of Specific Character Set (0008,0005) is not supported: " << characterSet;
--- a/UnitTestsSources/UnitTestsMain.cpp	Mon Aug 04 17:57:45 2014 +0200
+++ b/UnitTestsSources/UnitTestsMain.cpp	Mon Aug 04 18:12:21 2014 +0200
@@ -644,6 +644,14 @@
   ASSERT_EQ(Encoding_Utf8, StringToEncoding(EnumerationToString(Encoding_Utf8)));
   ASSERT_EQ(Encoding_Ascii, StringToEncoding(EnumerationToString(Encoding_Ascii)));
   ASSERT_EQ(Encoding_Latin1, StringToEncoding(EnumerationToString(Encoding_Latin1)));
+  ASSERT_EQ(Encoding_Latin2, StringToEncoding(EnumerationToString(Encoding_Latin2)));
+  ASSERT_EQ(Encoding_Latin3, StringToEncoding(EnumerationToString(Encoding_Latin3)));
+  ASSERT_EQ(Encoding_Latin4, StringToEncoding(EnumerationToString(Encoding_Latin4)));
+  ASSERT_EQ(Encoding_Latin5, StringToEncoding(EnumerationToString(Encoding_Latin5)));
+  ASSERT_EQ(Encoding_Cyrillic, StringToEncoding(EnumerationToString(Encoding_Cyrillic)));
+  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(ResourceType_Patient, StringToResourceType(EnumerationToString(ResourceType_Patient)));
   ASSERT_EQ(ResourceType_Study, StringToResourceType(EnumerationToString(ResourceType_Study)));