Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail 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; '(at': 0.04; 'insert': 0.05; 'subject:text': 0.05; 'none:': 0.07; '__init__': 0.09; 'args)': 0.09; 'encode': 0.09; 'main()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tcl/tk': 0.09; 'subject:question': 0.10; 'translate': 0.10; 'jan': 0.12; 'windows': 0.15; '236,': 0.16; '36,': 0.16; 'codec': 0.16; 'filename,': 0.16; 'group?': 0.16; 'key)': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'tcl': 0.16; 'tk.': 0.16; 'wrote:': 0.18; 'command': 0.22; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'skip:" 40': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'character': 0.29; '"",': 0.31; '25,': 0.31; 'correctly.': 0.31; 'workaround': 0.31; 'file': 0.32; 'know.': 0.32; 'open': 0.33; '(most': 0.33; 'not.': 0.33; 'skip:_ 10': 0.34; "can't": 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'idle': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'skip:c 50': 0.60; 'range': 0.61; 'times': 0.62; 'more': 0.64; 'prompt': 0.68; '(10': 0.84; '81,': 0.84; 'perspective.': 0.84; 'received:fios.verizon.net': 0.84; '1,000,000': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Newbie question about text encoding Date: Sat, 07 Mar 2015 01:11:01 -0500 References: <201502241957.t1OJvrJS015604@fido.openend.se> <9169f3b1-2ac7-42a3-8033-584f84b88a1f@googlegroups.com> <7a75a23c-4678-4d7a-a2ec-9e8fff4c07f8@googlegroups.com> <132d5ce6-f672-4eec-99f9-1cc9e88b94f3@googlegroups.com> <619e4cb5-1c4c-449b-a5d7-951101b32b45@googlegroups.com> <54f862ca$0$13014$c3e8da3$5496439d@news.astraweb.com> <01dd9b83-db3e-4e7d-9022-dc6af75eb570@googlegroups.com> <54f9bea1$0$12994$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425708701 news.xs4all.nl 2859 [2001:888:2000:d::a6]:51846 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87076 On 3/6/2015 11:20 AM, Rustom Mody wrote: > =3D=3D=3D=3D=3D=3D=3D=3D=3D > pp =3D "=F0=9F=92=A9" > print (pp) > =3D=3D=3D=3D=3D=3D=3D=3D=3D > Try open it in idle3 and you get (at least I get): > > $ idle3 ff.py > Traceback (most recent call last): > File "/usr/bin/idle3", line 5, in > main() > File "/usr/lib/python3.4/idlelib/PyShell.py", line 1562, in main > if flist.open(filename) is None: > File "/usr/lib/python3.4/idlelib/FileList.py", line 36, in open > edit =3D self.EditorWindow(self, filename, key) > File "/usr/lib/python3.4/idlelib/PyShell.py", line 126, in __init__ > EditorWindow.__init__(self, *args) > File "/usr/lib/python3.4/idlelib/EditorWindow.py", line 294, in __in= it__ > if io.loadfile(filename): > File "/usr/lib/python3.4/idlelib/IOBinding.py", line 236, in loadfil= e > self.text.insert("1.0", chars) > File "/usr/lib/python3.4/idlelib/Percolator.py", line 25, in insert > self.top.insert(index, chars, tags) > File "/usr/lib/python3.4/idlelib/UndoDelegator.py", line 81, in inse= rt > self.addcmd(InsertCommand(index, chars, tags)) > File "/usr/lib/python3.4/idlelib/UndoDelegator.py", line 116, in add= cmd > cmd.do(self.delegate) > File "/usr/lib/python3.4/idlelib/UndoDelegator.py", line 219, in do > text.insert(self.index1, self.chars, self.tags) > File "/usr/lib/python3.4/idlelib/ColorDelegator.py", line 82, in ins= ert > self.delegate.insert(index, chars, tags) > File "/usr/lib/python3.4/idlelib/WidgetRedirector.py", line 148, in = __call__ > return self.tk_call(self.orig_and_operation + args) > _tkinter.TclError: character U+1f4a9 is above the range (U+0000-U+FFFF)= allowed by Tcl > > So who/what is broken? tcl The possible workaround is for Idle to translate "=F0=9F=92=A9" to "\U000= 1f4a9"=20 (10 chars) before sending it to tk. But some perspective. In the console interpreter: >>> print("\U0001f4a9") Traceback (most recent call last): File "", line 1, in File "C:\Programs\Python34\lib\encodings\cp437.py", line 19, in encode= return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f4a9'=20 in posit ion 0: character maps to So what is broken? Windows Command Prompt. More perspective. tk/Idle *will* print *something* for every BMP char.=20 Command Prompt will not. It does not even do ucs-2 correctly. So=20 which is more broken? Windows Command Prompt. Who has perhaps=20 1,000,000 times more resources, Microsoft? or the tcl/tk group? I think = we all know. --=20 Terry Jan Reedy