Euro sign issue when reading an RTF file with Python

前端 未结 2 1719
北海茫月
北海茫月 2021-01-22 19:09

I need to generate a document in RTF using Python and pyRTF, everything is ok: I have no problem with accented letters, it accepts even the euro sign without errors, but instead

2条回答
  •  情深已故
    2021-01-22 19:54

    The good news is that you're not doing anything wrong. The bad news is that the RTF is being read as ISO 8859-1 regardless.

    >>> print u'€'.encode('iso-8859-15').decode('iso-8859-1')
    ¤
    

    You'll need to use a Unicode escape if you want it to be read properly.

    >>> print hex(ord(u'€'))
    0x20ac
    

提交回复
热议问题