By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,772 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,772 IT Pros & Developers. It's quick & easy.

Re: RTF Parsing

P: n/a
En Tue, 29 Jul 2008 10:08:21 -0300, Victor Subervi
I have this code:
def a():
chars = ['\\i0', '\\u0', '\\qc', '\\b0', '\\ql', '\\i', '\\u', '\\b',
rtf_markup = 'viewkind4\uc1\pard\nowidctlpar\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\\nowidctlpar\\qc...'

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

See the tutorial and the
gory details at

Gabriel Genellina

Jul 30 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.