Marcdump -c tries to make more readable strings
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Apr 2013 09:24:44 +0000 (11:24 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Apr 2013 09:24:44 +0000 (11:24 +0200)
For chr values 32 - 126 the charcter is produced verbatim.

util/marcdump.c

index e0491c4..f92204e 100644 (file)
@@ -398,7 +398,10 @@ static void dump(const char *fname, const char *from, const char *to,
                 {
                     if ((i & 15) == 0)
                         fprintf(cfile, "  \"");
                 {
                     if ((i & 15) == 0)
                         fprintf(cfile, "  \"");
-                    fprintf(cfile, "\\x%02X", p[i] & 255);
+                    if (p[i] < 32 || p[i] > 126)
+                        fprintf(cfile, "\" \"\\x%02X\" \"", p[i] & 255);
+                    else
+                        fputc(p[i], cfile);
 
                     if (i < r - 1 && (i & 15) == 15)
                         fprintf(cfile, "\"\n");
 
                     if (i < r - 1 && (i & 15) == 15)
                         fprintf(cfile, "\"\n");