]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
in ordrer to display the *stored* length when xxx.Print()
[gdcm.git] / src / gdcmUtil.cxx
index 40143310270811fa753301afa7bf6ac6663befc2..475d71c2ece3d5e43b7cca71b430bd84714e680c 100644 (file)
@@ -52,9 +52,9 @@ void gdcmDebug::Exit(int a) {
 }
 
 //-----------------------------------------------------------------------------
-gdcmVR      * gdcmGlobal::VR    = (gdcmVR*)0;
-gdcmTS      * gdcmGlobal::TS    = (gdcmTS*)0;
-gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
+gdcmVR      *gdcmGlobal::VR    = (gdcmVR *)0;
+gdcmTS      *gdcmGlobal::TS    = (gdcmTS *)0;
+gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0;
 gdcmGlobal gdcmGlob;
 
 gdcmGlobal::gdcmGlobal(void) {
@@ -71,15 +71,15 @@ gdcmGlobal::~gdcmGlobal() {
    delete Dicts;
 }
 
-gdcmVR * gdcmGlobal::GetVR(void) {
+gdcmVR *gdcmGlobal::GetVR(void) {
    return VR;
 }
 
-gdcmTS * gdcmGlobal::GetTS(void) {
+gdcmTS *gdcmGlobal::GetTS(void) {
    return TS;
 }
 
-gdcmDictSet * gdcmGlobal::GetDicts(void) {
+gdcmDictSet *gdcmGlobal::GetDicts(void) {
    return Dicts;
 }
 
@@ -113,7 +113,7 @@ void Tokenize (const std::string& str,
 
 ///////////////////////////////////////////////////////////////////////////
 // to prevent a flashing screen when non-printable character
-char * _cleanString(char *v) {
+char *_cleanString(char *v) {
    char *d;
    int i, l;
    l = strlen(v);
@@ -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);
 }