On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: > 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
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 -Mark -- http://mail.python.org/mailman/listinfo/python-list