From 5255afb72d1e7105fbb3cce9dbe27f4836aa48b9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 23 May 2003 02:59:06 +0000 Subject: Freak out properly when our input isnt ascii svn:r33 --- BibTeX.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'BibTeX.py') diff --git a/BibTeX.py b/BibTeX.py index bf849bd..d181256 100644 --- a/BibTeX.py +++ b/BibTeX.py @@ -240,9 +240,12 @@ class BibTeXEntry: d.append("%%%%% ERROR: Missing field\n") d.append("%% %s = {?????},\n"%f) continue + np = v.translate(ALLCHARS, PRINTINGCHARS) + if np: + d.append("%%%%% "+("ERROR: Non-ASCII characters: '%r'\n"%np)) d.append(" ") if invStrings.has_key(v): - s = "%s = %s," %(f, invStrings[v]) + s = "%s = %s,\n" %(f, invStrings[v]) else: s = "%s = {%s},\n" % (f, v) d.append(_split(s,width,indent)) @@ -269,7 +272,6 @@ class BibTeXEntry: print e return not errs - def _check(self): errs = [] if self.type == 'inproceedings': @@ -299,6 +301,9 @@ class BibTeXEntry: errs.append("ERROR: %s's booktitle doesn't start with 'Proceedings'" % self.key) for field, value in self.entries.items(): + if value.translate(ALLCHARS, PRINTINGCHARS): + errs.append("ERROR: %s.%s has non-ASCII characters"%( + self.key, field)) if field.startswith("www_") and field not in WWW_FIELDS: errs.append("ERROR: unknown www field %s"% field) if value.strip()[-1:] == '.' and \ @@ -724,6 +729,7 @@ def parseAuthor(s): return parsedAuthors ALLCHARS = "".join(map(chr,range(256))) +PRINTINGCHARS = "\t\n\r"+"".join(map(chr,range(32, 127))) LC_CHARS = "abcdefghijklmnopqrstuvwxyz" SV_DELCHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" -- cgit v1.2.3-70-g09d2