diff Core/Toolbox.cpp @ 2129:0c09d1af22f3

"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Nov 2016 17:44:10 +0100
parents e9e6ffbf0fd5
children dd609a99d39a
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Mon Nov 07 15:13:16 2016 +0100
+++ b/Core/Toolbox.cpp	Mon Nov 07 17:44:10 2016 +0100
@@ -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;