diff Core/Enumerations.cpp @ 1086:e56c3ed8d738

Parameter to set the default encoding for DICOM files without SpecificCharacterSet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Aug 2014 17:57:45 +0200
parents a811bdf8b8eb
children e07b90fb00eb
line wrap: on
line diff
--- a/Core/Enumerations.cpp	Mon Aug 04 12:16:50 2014 +0200
+++ b/Core/Enumerations.cpp	Mon Aug 04 17:57:45 2014 +0200
@@ -261,6 +261,47 @@
   }
 
 
+  const char* EnumerationToString(Encoding encoding)
+  {
+    switch (encoding)
+    {
+      case Encoding_Utf8:
+        return "Utf8";
+
+      case Encoding_Latin1:
+        return "Latin1";
+
+      case Encoding_Ascii:
+        return "Ascii";
+
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
+  Encoding StringToEncoding(const char* encoding)
+  {
+    std::string s(encoding);
+    Toolbox::ToUpperCase(s);
+
+    if (s == "UTF8")
+    {
+      return Encoding_Utf8;
+    }
+    else if (s == "LATIN1")
+    {
+      return Encoding_Latin1;
+    }
+    else if (s == "ASCII")
+    {
+      return Encoding_Ascii;
+    }
+
+    throw OrthancException(ErrorCode_ParameterOutOfRange);
+  }
+
+
   ResourceType StringToResourceType(const char* type)
   {
     std::string s(type);