file.write() of non-ASCII characters differs in Interpreted Python than in script run

Chris Angelico rosuav at gmail.com
Wed Aug 26 11:24:42 CEST 2015


On Wed, Aug 26, 2015 at 7:12 PM, RAH <rene.heymans at gmail.com> wrote:
> By the way my whole installation is defaulted to UTF-8:
>
> HTML:        <head><meta charset="utf-8"></head>
> Javascript:  <script type="text/javascript" charset="UTF-8">
> PuTTY:       >Translation>Character set translation>Remote character set>UTF-8
> Python code: # -*- coding: utf-8 -*-
> Linux:       $ echo $LANG ---> en_US.UTF-8

Check that from actually inside your web script - os.environ["LANG"]
should be "en_US.UTF-8". If it isn't, then that may be where your
difference between web and interactive is, and so you'll need to be
more explicit about encodings.

It's common for background processes to have restricted environments,
sometimes with LANG=C or similar.

ChrisA


More information about the Python-list mailing list