35 RTF_COLORDEF = "\\red{0:d}\\green{1:d}\\blue{2:d};" |
36 RTF_COLORDEF = "\\red{0:d}\\green{1:d}\\blue{2:d};" |
36 RTF_COLORDEFCLOSE = "}" |
37 RTF_COLORDEFCLOSE = "}" |
37 RTF_INFOOPEN = "{\\info " |
38 RTF_INFOOPEN = "{\\info " |
38 RTF_INFOCLOSE = "}" |
39 RTF_INFOCLOSE = "}" |
39 RTF_COMMENT = "{\\comment Generated by eric5's RTF export filter.}" |
40 RTF_COMMENT = "{\\comment Generated by eric5's RTF export filter.}" |
40 RTF_CREATED = "{\creatim\yr%Y\mo%m\dy%d\hr%H\min%M\sec%S}" # to be used by strftime |
41 RTF_CREATED = "{\creatim\yr%Y\mo%m\dy%d\hr%H\min%M\sec%S}" # to be used by strftime |
41 RTF_BODYOPEN = "" |
42 RTF_BODYOPEN = "" |
42 RTF_BODYCLOSE = "}" |
43 RTF_BODYCLOSE = "}" |
43 |
44 |
44 RTF_SETFONTFACE = "\\f" |
45 RTF_SETFONTFACE = "\\f" |
45 RTF_SETFONTSIZE = "\\fs" |
46 RTF_SETFONTSIZE = "\\fs" |
311 utf8Len = 4 |
312 utf8Len = 4 |
312 elif (utf8Ch[0] & 0xE0) == 0xE0: |
313 elif (utf8Ch[0] & 0xE0) == 0xE0: |
313 utf8Len = 3 |
314 utf8Len = 3 |
314 elif (utf8Ch[0] & 0xC0) == 0xC0: |
315 elif (utf8Ch[0] & 0xC0) == 0xC0: |
315 utf8Len = 2 |
316 utf8Len = 2 |
316 column -= 1 # will be incremented again later |
317 column -= 1 # will be incremented again later |
317 elif len(utf8Ch) == utf8Len: |
318 elif len(utf8Ch) == utf8Len: |
318 ch = utf8Ch.decode('utf8') |
319 ch = utf8Ch.decode('utf8') |
319 if ord(ch) <= 0xff: |
320 if ord(ch) <= 0xff: |
320 f.write("\\'{0:x}".format(ord(ch))) |
321 f.write("\\'{0:x}".format(ord(ch))) |
321 else: |
322 else: |
322 f.write("\\u{0:d}\\'{1:x}".format( |
323 f.write("\\u{0:d}\\'{1:x}".format( |
323 ord(ch), ord(ch) & 0xFF)) |
324 ord(ch), ord(ch) & 0xFF)) |
324 utf8Ch = b"" |
325 utf8Ch = b"" |
325 utf8Len = 0 |
326 utf8Len = 0 |
326 else: |
327 else: |
327 column -= 1 # will be incremented again later |
328 column -= 1 # will be incremented again later |
328 else: |
329 else: |
329 f.write(ch.decode()) |
330 f.write(ch.decode()) |
330 |
331 |
331 column += 1 |
332 column += 1 |
332 prevCR = ch == '\r' |
333 prevCR = ch == '\r' |