Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • hbb"Visually similar" Unicode to Windows-1252 conversion

    1 answers - 1113 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi,
    I'm using htmldoc (http://www.easysw.com/htmldoc/) to convert HTML files
    to PDF. Unfortunately, this software does not support Unicode, 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?
    Any help would be much appreciated. Also, if anyone knows another forum
    I could try asking in, that'd help too.
    Paul
    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.1 | | 1010 bytes | |

    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().

Re: hbb"Visually similar" Unicode to Windows-1252 conversion


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 4 =
QUESTION ON "Python"

EMSDN.COM