Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Unicode failure Date: Fri, 4 Dec 2015 18:28:22 -0500 Lines: 35 Message-ID: References: <20151204130738.76313c43@imp> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de mQEpJF/mmxh+30uML9TcfgKB04DO6vP+Q0QMYSEBk1NQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; '-*-': 0.07; 'skip:/ 10': 0.07; 'utf-8': 0.07; 'coding:': 0.09; 'encode': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'jan': 0.11; 'codec': 0.16; 'display,': 0.16; 'fail,': 0.16; 'ordinal': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'redundant,': 0.16; 'reedy': 0.16; 'subject:Unicode': 0.16; 'wrote:': 0.16; 'windows': 0.20; '3.x': 0.22; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'mostly': 0.27; 'device': 0.28; 'itself,': 0.29; 'windows,': 0.29; 'character': 0.29; 'print': 0.30; 'rules': 0.31; "can't": 0.32; 'idle': 0.33; 'traceback': 0.33; 'true.': 0.33; 'file': 0.34; 'text': 0.35; 'unicode': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'should': 0.36; 'received:71': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'display': 0.37; 'received:org': 0.37; 'thought': 0.37; 'to:addr:python.org': 0.40; 'mark': 0.40; 'skip:u 10': 0.61; 'entire': 0.61; 'default': 0.61; 'within': 0.64; 'soon': 0.65; 'here': 0.66; '3.4': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-71-185-227-36.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <20151204130738.76313c43@imp> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100022 On 12/4/2015 1:07 PM, D'Arcy J.M. Cain wrote: > I thought that going to Python 3.4 would solve my Unicode issues Within Python itself, that should be mostly true. As soon as you send=20 text to a display, the rules of the display device take over. > > #! /usr/bin/python3 > # -*- coding: UTF-8 -*- Redundant, as this is the default for 3.x > 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 > print(u"\N{TRADE MARK SIGN}") > UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in > position 0: ordinal not in range(128) Tk widgets, and hence IDLE windows, will print any character from \u0000 = to \uffff without raising, even if the result is blank or =EF=BF=BF. Hig= her=20 codepoints fail, but allowing the entire BMP is better than any Windows=20 codepage. --=20 Terry Jan Reedy