Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45726 > unrolled thread

Python Windows release and encoding

Started by"Absalom K." <absalom@emet.tnk>
First post2013-05-22 12:10 +0000
Last post2013-05-22 14:39 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Python Windows release and encoding "Absalom K." <absalom@emet.tnk> - 2013-05-22 12:10 +0000
    Re: Python Windows release and encoding Peter Otten <__peter__@web.de> - 2013-05-22 14:39 +0200

#45726 — Python Windows release and encoding

From"Absalom K." <absalom@emet.tnk>
Date2013-05-22 12:10 +0000
SubjectPython Windows release and encoding
Message-ID<519cb599$0$2290$426a74cc@news.free.fr>
Hi, I am working on Linux; a friend of mine sends to me python files from
his Windows release. He uses the editor coming with the release; he runs
his code from the editor by using a menu (or some F5 key I think).

He doesn't declare any encoding in his source file; when I want to try
his code, I have an error since he obviously uses non-ascii characters.
As far as I can see, he uses utf8 without knowing it. I add the UTF8
declaration, run the code, and everything is fine.

Then I tell him to add the utf-8 declaration; but now he has an error
when running his file from the Windows editor.

Finally, he told me he could run the file by declaring the latin-1
encoding.

But I want to understand exactly:
  a) what is the encoding used by the editor coming in the Windows release?
  b) why doesn't he need to declare the encoding (I need it on Linux for
     the very same files)?

Best regards, ak.

[toc] | [next] | [standalone]


#45727

FromPeter Otten <__peter__@web.de>
Date2013-05-22 14:39 +0200
Message-ID<mailman.1962.1369226349.3114.python-list@python.org>
In reply to#45726
Absalom K. wrote:

> Hi, I am working on Linux; a friend of mine sends to me python files from
> his Windows release. He uses the editor coming with the release; he runs
> his code from the editor by using a menu (or some F5 key I think).
> 
> He doesn't declare any encoding in his source file; when I want to try
> his code, I have an error since he obviously uses non-ascii characters.
> As far as I can see, he uses utf8 without knowing it. I add the UTF8
> declaration, run the code, and everything is fine.
> 
> Then I tell him to add the utf-8 declaration; but now he has an error
> when running his file from the Windows editor.
> 
> Finally, he told me he could run the file by declaring the latin-1
> encoding.
> 
> But I want to understand exactly:
>   a) what is the encoding used by the editor coming in the Windows
>   release? b) why doesn't he need to declare the encoding (I need it on
>   Linux for
>      the very same files)?
> 
> Best regards, ak.

Your friend may be using an old version of Python. Quoting

<http://www.python.org/dev/peps/pep-0263/>

"""
    For backwards-compatibility with existing code which currently
    uses non-ASCII in string literals without declaring an encoding,
    the implementation will be introduced in two phases:

    1. Allow non-ASCII in string literals and comments, by internally
       treating a missing encoding declaration as a declaration of
       "iso-8859-1". This will cause arbitrary byte strings to
       correctly round-trip between step 2 and step 5 of the
       processing, and provide compatibility with Python 2.2 for
       Unicode literals that contain non-ASCII bytes.

       A warning will be issued if non-ASCII bytes are found in the
       input, once per improperly encoded input file.

    2. Remove the warning, and change the default encoding to "ascii".

    [...]

    Implementation of steps 1 and 2 above were completed in 2.3,
    except for changing the default encoding to "ascii".

    The default encoding was set to "ascii" in version 2.5.
 """

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web