Another 2 to 3 mail encoding problem

MRAB python at mrabarnett.plus.com
Thu Aug 27 16:02:32 EDT 2020


On 2020-08-27 17:29, Barry Scott wrote:
> 
> 
>> On 26 Aug 2020, at 16:10, Chris Green <cl at isbd.net> wrote:
>> 
>>  UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in position 4: ordinal not in range(128)
>> 
>> So what do I need to do to the message I'm adding with mbx.add(msg) to
>> fix this?  (I assume that's what I need to do).
> 
>>>> import unicodedata
>>>> unicodedata.name('\ufeff')
> 'ZERO WIDTH NO-BREAK SPACE'
> 
> I guess the editor you use to compose the text is adding that to your message.
> 
That's used as a BOM (Byte-Order Marker) at the start of UTF16-BE.
It's also used at the start of UTF-8-SIG.


More information about the Python-list mailing list