Re: RTF Parsing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriel Genellina

    Re: RTF Parsing

    En Tue, 29 Jul 2008 10:08:21 -0300, Victor Subervi
    <victorsubervi@ gmail.comescrib i�:
    Hi;
    I have this code:
    def a():
    chars = ['\\i0', '\\u0', '\\qc', '\\b0', '\\ql', '\\i', '\\u', '\\b',
    '\\yz']
    rtf_markup = 'viewkind4\uc1\ pard\nowidctlpa r\qc\i\f0\fs36 Who is like the
    Beast? Who can wage war against him?\par'
    The \ is an escape character inside string literals. '\n' contains a
    *single* character and it's the same as chr(10). '\f0' is two characters
    long, not three. You have two alternatives:

    a) double each \ (because \\ is interpreted as a single backslash):
    rtf_markup = 'viewkind4\\uc1 \\pard\\nowidct lpar\\qc...'

    b) use raw strings - that is, prefix each string literal with a small r:
    rtf_markup = r'viewkind4\uc1 \pard\nowidctlp ar...'

    See the tutorial
    http://docs.python.org/tut/node5.htm...00000000000000 and the
    gory details at http://docs.python.org/ref/strings.html

    --
    Gabriel Genellina

Working...