hello Uli,<br><br>thanks, I think you hit the nail on it's head, <br>PyScripter indeed changes default encoding<br>but ..<br><br><div class="gmail_quote">On Wed, Sep 22, 2010 at 9:16 AM, Ulrich Eckhardt <span dir="ltr"><<a href="mailto:eckhardt@satorlaser.com">eckhardt@satorlaser.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">Stef Mientki wrote:<br>
> When running this python application from the command line ( or launched<br>
> from another Python program), the wrong character encoding (probably<br>
> windows-1252) is used.<br>
<br>
</div>Rule #1: If you know the correct encoding, set it yourself. This<br>
particularly applies to files you open yourself (use the codec module). In<br>
the case of your program, I guess the stream with the faulty encoding is<br>
stdin/stdout, who's encoding is guessed by Python, but which you can<br>
override. Check sys.stdin.encoding.<br></blockquote><div>None,<br>So I guess it's using the windows default, which is windows-1252,<br>and it's ReadOnly so I can't change it.<br><br>Can you tell me how I change the default Python encoding,<br>
or how to set the encoding in Popen, this is the statement I use to launch my program<br><br>subprocess.Popen ( [ 'python', Filename ] )<br><br>thanks,<br>Stef Mientki<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im"><br>
> When I run this program from PyScripter ( either internal engine or remote<br>
> engine), MSHTML shows the correct character encoding,<br>
> perfect!<br>
<br>
</div>Interesting, I would say that PyScripter sets up the environment<br>
differently, so that Python guesses a different encoding. Also make sure<br>
both are calling the same Python, I get 'cp850' or 'US-ASCII' depending on<br>
whether I call the native MS Windows Python or the Cygwin Python.<br>
<div class="im"><br>
> In the main file, and in the major files that constains strings I've added<br>
> the following 2 lines:<br>
> # -*- coding: utf-8 -*-<br>
> from __future__ import absolute_import, unicode_literals<br>
<br>
</div>This shouldn't matter. This just tells Python that the sourcecode itself is<br>
encoded in UTF-8 and that you want to use Unicode names in your string<br>
literals, it doesn't affect the output of your program.<br>
<br>
Uli<br>
<br>
--<br>
Sator Laser GmbH<br>
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932<br>
<font color="#888888"><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>