summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-04-15 13:29:04 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-04-15 13:29:04 -0400
commit11e213203b7153d0a947bb5221cce0185fea219d (patch)
tree86d0b974e0b9e6bba9576090dc5b500d0fe8ab52
parenta07c1f2555e26a6a21d1668bdfd8c28c01c559a6 (diff)
downloadpygments-11e213203b7153d0a947bb5221cce0185fea219d.tar.gz
If encoding fails use ? as ANSI fallback character
-rw-r--r--pygments/formatters/rtf.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index 9d87e8f1..4b03f8a7 100644
--- a/pygments/formatters/rtf.py
+++ b/pygments/formatters/rtf.py
@@ -82,11 +82,11 @@ class RtfFormatter(Formatter):
buf = []
for c in text:
if ord(c) > 128:
- ansic = c.encode(encoding, 'ignore') or '?'
- if ord(ansic) > 128:
+ ansic = c.encode(encoding, 'ignore')
+ if ansic and ord(ansic) > 128:
ansic = '\\\'%x' % ord(ansic)
else:
- ansic = c
+ ansic = '?'
buf.append(r'\ud{\u%d%s}' % (ord(c), ansic))
else:
buf.append(str(c))