Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Laura Creighton Newsgroups: comp.lang.python Subject: Re: cannot open file with non-ASCII filename Date: Mon, 14 Dec 2015 19:51:45 +0100 Lines: 33 Message-ID: References: <566F0BD0.8020106@udel.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de z1KTTyNq9j9HSAaTvryILAy8EFIe95klYcUX30zmU1NQ== 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; 'root': 0.04; '-*-': 0.07; 'filenames': 0.07; 'subject:file': 0.07; 'coding:': 0.09; 'non- ascii': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'unicode,': 0.09; 'python': 0.10; 'jan': 0.11; '>on': 0.16; 'filenames.': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:non': 0.16; 'tk()': 0.16; 'wrote:': 0.16; 'laura': 0.18; 'windows': 0.20; '2015': 0.20; '3.x': 0.22; 'ascii': 0.22; 'class,': 0.22; 'tkinter': 0.22; 'am,': 0.23; '(or': 0.23; '(where': 0.23; 'dec': 0.23; 'performing': 0.23; 'this:': 0.23; 'import': 0.24; 'mon,': 0.24; 'restrict': 0.27; 'fine': 0.28; '-0500,': 0.29; 'received:se': 0.29; 'themselves': 0.29; 'url:mailman': 0.30; 'fixed': 0.31; 'core': 0.32; 'possibly': 0.32; 'url:python': 0.33; 'him.': 0.33; 'url:listinfo': 0.34; 'text': 0.35; 'unicode': 0.35; 'should': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'files': 0.38; 'subject:-': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'header:Message-Id:1': 0.61; 'further': 0.62; 'making': 0.62; '>with': 0.84; 'header:In-reply-to:1': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openend.se; s=default; t=1450119107; bh=QB0+SC2WKxQIJoyr49K/YPFL9406bzSNZzxutv7PSS8=; h=To:From:Subject:In-reply-to:References:Date:From; b=KAVLJkTtKXeyFxNp1E5fLUqmvURurrroTgXCiUfpxZkk6oqtwUqei/R5JnPDOdGQ/ tNh9U5OIZbXcOvQICiTtMKXS82+PVP01L3lf96VgOMyGH43WqVuwX0l4LdjB5rhoYa oriZEhFsMv+OjaTkEnu+fYDosLaRO+Cq43JxVNG0= In-reply-to: <566F0BD0.8020106@udel.edu> Comments: In-reply-to Terry Reedy message dated "Mon, 14 Dec 2015 13:34:56 -0500." Content-ID: <18007.1450119105.1@fido> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Mon, 14 Dec 2015 19:51:47 +0100 (CET) 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:100420 In a message of Mon, 14 Dec 2015 13:34:56 -0500, Terry Reedy writes: >On 12/14/2015 11:24 AM, Ulli Horlacher wrote: >> With Python 2.7.11 on Windows 7 my users cannot open/read files with >> non-ASCII filenames. > >Right. They should either restrict themselves to ascii (or possibly >latin-1) filenames or use current 3.x. This is one of the (known) >unicode problems fixed in 3.x by making unicode the core text class, >replacing the implementation of unicode, and performing further work >with the new implementation. > >-- >Terry Jan Reedy > >-- >https://mail.python.org/mailman/listinfo/python-list Given that Ulli is in Germany, latin-1 is likely to work fine for him. And you do it like this: # -*- coding: latin-1 -*- from Tkinter import * root = Tk() s = 'Välkommen till Göteborg' # Welcome to Gothenburg (where I live) u = unicode(s, 'iso8859-1') Label(root, text=u).pack() root.mainloop() Laura