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


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

Re: Unicode failure

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2015-12-04 22:54 +0000
Last post2015-12-04 22:54 +0000
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.


Contents

  Re: Unicode failure Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-12-04 22:54 +0000

#100019 — Re: Unicode failure

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2015-12-04 22:54 +0000
SubjectRe: Unicode failure
Message-ID<mailman.211.1449269691.14615.python-list@python.org>
On 4 Dec 2015 22:34, "D'Arcy J.M. Cain" <darcy@vybenetworks.com> 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 important thing is not the default encoding but the encoding associated
with stdout. Try printing sys.stdout.encoding to see what that is. It may
depend what terminal you're trying to print out in. Are you using cmd.exe?
If on Unix what's the value of LANG environment variable?

--
Oscar

[toc] | [standalone]


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


csiph-web