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


Groups > comp.lang.python > #29093

Re: Least-lossy string.encode to us-ascii?

Date 2012-09-13 18:54 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: Least-lossy string.encode to us-ascii?
References <50524F6F.6070604@tim.thechases.com> <k2tqne$gie$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.654.1347580392.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 09/13/12 18:36, Terry Reedy wrote:
> On 9/13/2012 5:26 PM, Tim Chase wrote:
>> I've got a bunch of text in Portuguese and to transmit them, need to
>> have them in us-ascii (7-bit).  I'd like to keep as much information
>> as possible,just stripping accents, cedillas, tildes, etc.
> 
> 'keep as much information as possible' would mean an effectively 
> lossless transliteration, which you could do with a dict.
> {<o-with-accent>: 'o', <c-cedilla>: 'c,' (or pick something that would 
> never occur in normal text of the sort you are transmitting), ...}

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 :-)

-tkc


Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Least-lossy string.encode to us-ascii? Tim Chase <python.list@tim.thechases.com> - 2012-09-13 18:54 -0500
  Re: Least-lossy string.encode to us-ascii? Mark Tolonen <metolone@gmail.com> - 2012-09-13 19:09 -0700
    Re: Least-lossy string.encode to us-ascii? Tim Chase <python.list@tim.thechases.com> - 2012-09-13 21:34 -0500
      Re: Least-lossy string.encode to us-ascii? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-14 04:05 +0000
    Re: Least-lossy string.encode to us-ascii? Terry Reedy <tjreedy@udel.edu> - 2012-09-14 16:57 -0400
  Re: Least-lossy string.encode to us-ascii? Mark Tolonen <metolone@gmail.com> - 2012-09-13 19:09 -0700

csiph-web