Commits

Gaurav Jain committed e6ecd9e

If encoding fails use ? as ANSI fallback character

Comments (0)

Files changed (1)

pygments/formatters/rtf.py

         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))