]> Creatis software - gdcm.git/commitdiff
to avoid printing troubles with odd length fields padded with zero to become even
authorjpr <jpr>
Thu, 22 Jan 2004 10:16:26 +0000 (10:16 +0000)
committerjpr <jpr>
Thu, 22 Jan 2004 10:16:26 +0000 (10:16 +0000)
src/gdcmUtil.cxx
src/gdcmVR.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);
 }
 
index f002d0a083aa98525580bd8c0f11e3dfcd0c720b..3732f2bd60cc31a24a23d4ea7baaa52c9ad700a4 100644 (file)
@@ -76,7 +76,7 @@ void gdcmVR::Print(std::ostream &os)
 /**
  * \ingroup gdcmVR
  * \brief   Get the count for an element
- * @param   Key key to count
+ * @param   key key to count
  */
 int gdcmVR::Count(VRKey key) 
 {