diff OrthancServer/FromDcmtkBridge.cpp @ 1928:84c7eaeb5244

Configuration::GetDefaultEncoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Mar 2016 14:12:31 +0100
parents b60f27664b8f
children cda5b0ab4ce5
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -37,9 +37,9 @@
 #endif
 
 #include "FromDcmtkBridge.h"
-#include "OrthancInitialization.h"
 #include "../Core/Logging.h"
 #include "../Core/Toolbox.h"
+#include "../Core/Uuid.h"
 #include "../Core/OrthancException.h"
 
 #include <list>
@@ -270,11 +270,10 @@
   }
 
 
-  Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset)
+  Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset,
+                                           Encoding defaultEncoding)
   {
-    // By default, Latin1 encoding is assumed
-    std::string s = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1");
-    Encoding encoding = s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str());
+    Encoding encoding = defaultEncoding;
 
     OFString tmp;
     if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good())
@@ -305,9 +304,11 @@
   }
 
 
-  void FromDcmtkBridge::Convert(DicomMap& target, DcmDataset& dataset)
+  void FromDcmtkBridge::Convert(DicomMap& target, 
+                                DcmDataset& dataset,
+                                Encoding defaultEncoding)
   {
-    Encoding encoding = DetectEncoding(dataset);
+    Encoding encoding = DetectEncoding(dataset, defaultEncoding);
 
     target.Clear();
     for (unsigned long i = 0; i < dataset.card(); i++)
@@ -786,10 +787,11 @@
                                DcmDataset& dataset,
                                DicomToJsonFormat format,
                                DicomToJsonFlags flags,
-                               unsigned int maxStringLength)
+                               unsigned int maxStringLength,
+                               Encoding defaultEncoding)
   {
     target = Json::objectValue;
-    DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset));
+    DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset, defaultEncoding));
   }