Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: how to decode rtf characterset ?

Reply
Thread Tools

Re: how to decode rtf characterset ?

 
 
MRAB
Guest
Posts: n/a
 
      02-01-2010
Stef Mientki wrote:
> hello,
>
> I want to translate rtf files to unicode strings.
> I succeeded in remove all the tags,
> but now I'm stucked to the special accent characters,
> like :
>
> "Vóór"
>
> the character "ó" is represented by the string r"\'f3",
> or in bytes: 92, 39,102, 51
>
> so I think I need a way to translate that into the string r"\xf3"
> but I can't find a way to accomplish that.
>
> a
> Any suggestions are very welcome.
>

Change r"\'f3" to r"\xf3" and then decode to Unicode:

>>> s = r"\'f3"
>>> s = s.replace(r"\'", r"\x").decode("unicode_escape")
>>> print s

ó
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: what do you think on my summary on C, for 13-15 years studentin .rtf format [to cut and paste in a .rtf file] Kleuskes & Moos C Programming 8 10-13-2011 08:51 AM
javax.mail.internet.MimeMessage.setSubject problem with characterset (UTF-8) Zsolt Java 0 04-06-2004 09:38 AM
Doing a 'mail merge' with RTF files (aka RTF templates) Tony Perl Misc 2 08-27-2003 08:12 AM
Re: characterset declaration picayunish HTML 2 08-10-2003 02:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57