]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
in ordrer to display the *stored* length when xxx.Print()
[gdcm.git] / src / gdcmUtil.cxx
index b642db190e39a3950a25123f7b6e4b27e2f6d39c..475d71c2ece3d5e43b7cca71b430bd84714e680c 100644 (file)
@@ -131,12 +131,20 @@ char *_cleanString(char *v) {
 // to prevent a flashing screen when non-printable character
 std::string _CreateCleanString(std::string s) {
   std::string str=s;
-  for(int i=0;i<str.size();i++)
+  int n = str.size();
+  for(int i=0;i<n-1;i++)
   {
     if(!isprint(str[i]))
       str[i]='.';
   }
-
+  if(!isprint(str[n])) { // to avoid trouble with odd length fields
+                        // padded with zeo to become even
+  
+     if (str[n] == '\0') 
+        str[n] = ' ';
+     else
+        str[n] = '.';
+  }
   return(str);
 }