File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 66This module is potentially compatible with RTF versions up to 1.9.1,
77but may not ignore all necessary control groups.
88"""
9- import string , re , itertools
9+ import string , re , itertools , struct
1010
1111from pyth import document
1212from pyth .format import PythReader
@@ -504,7 +504,11 @@ def handle_control_symbol(self, symbol):
504504
505505
506506 def handle_u (self , codepoint ):
507- self .content .append (unichr (int (codepoint )))
507+ # This ridiculous trick gives a surrogate pair for
508+ # non-BMP codepoints on narrow Pythons, which is
509+ # probably better than crashing
510+ char = struct .pack ('<L' , 0x10000 ).decode ('utf-32' )
511+ self .content .append (char )
508512 self .content .append (Skip (self .props .get ('unicode_skip' , 1 )))
509513
510514
You can’t perform that action at this time.
0 commit comments