Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:skip:s 10': 0.05; 'cc:addr:python-list': 0.10; ':-)': 0.13; '(may': 0.16; '-tkc': 0.16; 'csv': 0.16; 'decode': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'stdlib.': 0.16; 'stripped': 0.16; 'us-ascii': 0.16; 'wrote:': 0.17; 'tim': 0.18; '>>>': 0.18; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'chase': 0.29; '8bit%:5': 0.29; 'ends': 0.30; 'thursday,': 0.30; 'file': 0.32; 'print': 0.32; 'goes': 0.33; 'web,': 0.33; 'requiring': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'but': 0.36; 'characters': 0.36; 'possible': 0.37; 'keeps': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'skip:l 20': 0.38; 'nothing': 0.38; 'subject:-': 0.40; 'end': 0.40; 'skip:u 10': 0.60; 'etc),': 0.84; 'received:50.22': 0.84; 'wanted,': 0.84 Date: Thu, 13 Sep 2012 21:34:52 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Mark Tolonen Subject: Re: Least-lossy string.encode to us-ascii? References: <50524F6F.6070604@tim.thechases.com> <8a35c480-7594-4202-afe8-f03db9418301@googlegroups.com> In-Reply-To: <8a35c480-7594-4202-afe8-f03db9418301@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347590022 news.xs4all.nl 6848 [2001:888:2000:d::a6]:40247 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29103 On 09/13/12 21:09, Mark Tolonen wrote: > On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: >> Vlastimil's solution kept the characters but stripped them of their >> accents/tildes/cedillas/etc, doing just what I wanted, all using the >> stdlib. Hard to do better than that :-) > > How about using UTF-7 for transmission and decode on the other end? This keeps the transmission all 7-bit, and no loss. > > >>> s=u"serviço móvil".encode('utf-7') > >>> print s > servi+AOc-o m+APM-vil > >>> print s.decode('utf-7') > serviço móvil Nice if I control both ends of the pipe. Unfortunately, I only control what goes in, and I want it to be as un-screw-uppable as possible when it comes out the other end (may be web, CSV files, PDFs, FTP'ed file dumps, spreadsheets, word-processing documents, etc), and us-ascii is the lowest-common-denominator of unscrewuppableness while requiring nothing of the the other end. :-) -tkc