Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100020 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2015-12-05 00:03 +0100 |
| Last post | 2015-12-05 00:03 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Unicode failure Peter Otten <__peter__@web.de> - 2015-12-05 00:03 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2015-12-05 00:03 +0100 |
| Subject | Re: Unicode failure |
| Message-ID | <mailman.212.1449270228.14615.python-list@python.org> |
D'Arcy J.M. Cain wrote:
> I thought that going to Python 3.4 would solve my Unicode issues but it
> seems I still don't understand this stuff. Here is my script.
>
> #! /usr/bin/python3
> # -*- coding: UTF-8 -*-
> import sys
> print(sys.getdefaultencoding())
> print(u"\N{TRADE MARK SIGN}")
>
> And here is my output.
>
> utf-8
> Traceback (most recent call last):
> File "./g", line 5, in <module>
> print(u"\N{TRADE MARK SIGN}")
> UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in
> position 0: ordinal not in range(128)
>
> What am I missing?
"""The character encoding is platform-dependent. Under Windows, if the
stream is interactive (that is, if its isatty() method returns True), the
console codepage is used, otherwise the ANSI code page. Under other
platforms, the locale encoding is used (see locale.getpreferredencoding()).
"""
https://docs.python.org/dev/library/sys.html#sys.stdout
Back to top | Article view | comp.lang.python
csiph-web