diff Framework/Orthanc/Core/Toolbox.cpp @ 12:9220cf4a63d5

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 14:14:34 +0100
parents 2dbe613f6c93
children 0b9034112fde
line wrap: on
line diff
--- a/Framework/Orthanc/Core/Toolbox.cpp	Wed Oct 26 12:14:03 2016 +0200
+++ b/Framework/Orthanc/Core/Toolbox.cpp	Wed Nov 09 14:14:34 2016 +0100
@@ -103,7 +103,7 @@
 #endif
 
 
-#if ORTHANC_PUGIXML_ENABLED == 1
+#if ORTHANC_ENABLE_PUGIXML == 1
 #include "ChunkedBuffer.h"
 #include <pugixml.hpp>
 #endif
@@ -844,6 +844,23 @@
   }
 
 
+  bool Toolbox::IsAsciiString(const void* data,
+                              size_t size)
+  {
+    const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
+
+    for (size_t i = 0; i < size; i++, p++)
+    {
+      if (*p > 127 || (*p != 0 && iscntrl(*p)))
+      {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+
   std::string Toolbox::ConvertToAscii(const std::string& source)
   {
     std::string result;
@@ -1190,7 +1207,7 @@
 #endif
 
 
-#if ORTHANC_PUGIXML_ENABLED == 1
+#if ORTHANC_ENABLE_PUGIXML == 1
   class ChunkedBufferWriter : public pugi::xml_writer
   {
   private: