From: ben Date: Sat, 2 Dec 2006 14:02:35 +0000 (+0000) Subject: Adjust ps_string so that it escapes characters above 126. This makes X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/commitdiff_plain/d4319ca364fcc45978174e8c443f20bc05fb5979 Adjust ps_string so that it escapes characters above 126. This makes Halibut's output 7-bit clean, which seems the best approach in PostScript. git-svn-id: svn://svn.tartarus.org/sgt/halibut@6950 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/bk_ps.c b/bk_ps.c index f66420a..86b8465 100644 --- a/bk_ps.c +++ b/bk_ps.c @@ -46,7 +46,7 @@ void ps_backend(paragraph *sourceform, keywordlist *keywords, fprintf(fp, "%%!PS-Adobe-3.0\n"); fprintf(fp, "%%%%Creator: Halibut, %s\n", version); - fprintf(fp, "%%%%DocumentData: Clean8Bit\n"); + fprintf(fp, "%%%%DocumentData: Clean7Bit\n"); fprintf(fp, "%%%%LanguageLevel: 1\n"); for (pageno = 0, page = doc->pages; page; page = page->next) pageno++; @@ -315,9 +315,13 @@ static void ps_string(FILE *fp, char const *str) { fprintf(fp, "("); for (c = str; *c; c++) { - if (*c == '(' || *c == ')' || *c == '\\') - fputc('\\', fp); - fputc(*c, fp); + if (*c < ' ' || *c > '~') { + fprintf(fp, "\\%03o", 0xFF & (int)*c); + } else { + if (*c == '(' || *c == ')' || *c == '\\') + fputc('\\', fp); + fputc(*c, fp); + } } fprintf(fp, ")"); }