Frank Moore wrote:
> Hi,
> 
> I'm getting the following error when I try and write some HTML with 
> German text in it.
> 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in 
> position 1367: ordinal not in range(128)
> 
> This was my code:
> 
>       html_text = open(inFile, 'r').read()
>      # ... do some processing on html_text
>       file(outFile, 'w').write(html_text)
> 
> I've now read the 'Unicode - How To' by AMKuchling and changed the code to:
> 
>       html_text = codecs.open(inFile, encoding='utf-8').read()
>      # ... do some processing on html_text
>       f = codecs.open(outFile, encoding='utf-8', mode='w')
>       f.write(html_text)
> 
> but I'm still getting the error.
> Does anybody know what I'm doing wrong?

Was it exactly the same error in both cases? Can you show us the whole 
error message with the traceback?

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to