[wxPython-users] "Visually similar" Unicode to Windows-1252 conversion

Robin Dunn robin at alldunn.com
Mon Sep 4 10:47:58 PDT 2006


Paul Johnston wrote:
> Hi,
> 
> I'm using htmldoc (http://www.easysw.com/htmldoc/) to convert HTML files 
> to PDF. Unfortunately, this software does not support Unicode, 

What about UTF-8?

> so I have 
> to encode my strings as Windows-1252. To avoid errors, I've using the 
> "replace" mode s.encode('cp1252', 'replace'). This does a "strict" 
> conversion in that say U+2013 (En Dash) is replaced by a question mark. 
> What I'd really like is a "visual approximation" conversion, so U+2013 
> would be replaced by an ASCII minus sign.
> 
> Now, I know Windows can do this. Using the ANSI version of wxPython, if 
> you enter unicode characters into a text box, this conversion is done 
> before the non-unicode string is returned. So, how can I access that 
> same conversion from Python?

It may be being done in the control itself.  wxPython just does the 
equivalent to the s.encode() using the encoding returned by 
wx.GetDefaultPyEncoding().


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list