email and unicode

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Apr 18 12:09:22 CEST 2010


On Sun, 18 Apr 2010 03:02:23 -0700, janwillem wrote:

> How can you get the unicode file name into the replace string of line 35
> of the snippet:
> replace = ReplaceString % dict(content_type=ct,
>                                        filename=fn,
>                                        params=params)
> without getting this nasty error message about ascii encoding?

Completely untested...

fn = fn.encode('utf-8')
replace = ReplaceString % dict(
          content_type=ct, filename=fn, params=params)



-- 
Steven



More information about the Python-list mailing list