7stud bbxx789_0...@yahoo.com (7) wrote:
7 Thanks for the response. My OS is mac osx 10.4.11. I'm not really
7 sure how to check my locale settings. Here is some stuff I tried:
7 $ echo $LANG
7 $ echo $LC_ALL
7 $ echo $LC_CTYPE
7 $ locale
7 LANG=
7 LC_COLLATE=C
7 LC_CTYPE=C
7 LC_MESSAGES=C
On Aug 25, 6:34 am, Nobody nob...@nowhere.com wrote:
The underlying OS primitive can only handle bytes. If you read or write a
(unicode) string, Python needs to know which encoding is used. For Python
file objects created by the user (via open() etc), you can specify the
encoding; for those
Have you considered including an encoding line at the top of your file, as
described in PEP 0263:
http://www.python.org/dev/peps/pep-0263/
I just ran into a similar error, but it went away when I included
# coding: utf-8
as the first line in my file.
--
On Aug 24, 10:09 pm, Ned Deily n...@acm.org wrote:
In article
e5e2ec2e-2b4a-4ca8-8c0f-109e5f4eb...@v23g2000pro.googlegroups.com,
7stud bbxx789_0...@yahoo.com wrote:
On Aug 24, 2:41 pm, Martin v. Löwis mar...@v.loewis.de wrote:
I can't figure out a way to programatically set the
On Tue, 25 Aug 2009 03:41:54 -0700, 7stud wrote:
Why does echoing $LC_ALL or $LC_CTYPE just give me a blank string?
Because the variables aren't set.
The default locale for a particular category (e.g. LC_CTYPE) is taken from
$LC_ALL if that is set, otherwise $LC_CTYPE, otherwise $LANG,
==python 2.6 ==
import sys
print sys.getdefaultencoding()
s = u\u20ac
print s.encode(utf-8)
$ python2.6 1test.py
ascii
€
=python 3.1 ===
import sys
print(sys.getdefaultencoding())
s = €
print(s.encode(utf-8))
print(s)
$ python3.1 1test.py
utf-8
b'\xe2\x82\xac'
Traceback
I don't understand why I'm getting an encode error in python 3.1.
The default encoding is not relevant here at all. Look at
sys.stdout.encoding.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 24, 9:56 am, Martin v. Löwis mar...@v.loewis.de wrote:
I don't understand why I'm getting an encode error in python 3.1.
The default encoding is not relevant here at all. Look at
sys.stdout.encoding.
Regards,
Martin
Hi,
Thanks for the response. I get US-ASCII for both 2.6 and
7stud wrote:
python 3.1 won't let me
explicitly encode my unicode string
Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail.
and python 3.1 implicitly does
the encoding with the wrong codec.
That's not a Python problem, though. Your terminal is configured for
On Aug 24, 12:19 pm, Stefan Behnel stefan...@behnel.de wrote:
7stud wrote:
python 3.1 won't let me
explicitly encode my unicode string
Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail.
As you should be able to see in the python 3.1 example I posted, I did
not
I can't figure out a way to programatically set the encoding for
sys.stdout. So where does that leave me?
You should be setting the terminal encoding administratively, not
programmatically.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 24, 2:41 pm, Martin v. Löwis mar...@v.loewis.de wrote:
I can't figure out a way to programatically set the encoding for
sys.stdout. So where does that leave me?
You should be setting the terminal encoding administratively, not
programmatically.
The terminal encoding has always
You should be setting the terminal encoding administratively, not
programmatically.
The terminal encoding has always been utf-8. It was not set
programmatically.
It seems to me that python 3.1's string handling is broken.
Apparently, in python 3.1 I am unable to explicitly set the
In article
e5e2ec2e-2b4a-4ca8-8c0f-109e5f4eb...@v23g2000pro.googlegroups.com,
7stud bbxx789_0...@yahoo.com wrote:
On Aug 24, 2:41 pm, Martin v. Löwis mar...@v.loewis.de wrote:
I can't figure out a way to programatically set the encoding for
sys.stdout. So where does that leave me?
14 matches
Mail list logo