Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29177
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <wxjmfauth@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'case.': 0.05; 'subject:skip:s 10': 0.05; 'preserves': 0.09; 'scripts,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; ':-)': 0.13; "'replace')": 0.16; "'strict')": 0.16; 'elephant': 0.16; 'us-ascii': 0.16; 'usage,': 0.16; '\xc3\xa9crit\xc2\xa0:': 0.16; 'tim': 0.18; '>>>': 0.18; "i'd": 0.22; 'cc:2**0': 0.23; 'task': 0.23; "i've": 0.23; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'coding': 0.27; 'possible,': 0.27; "doesn't": 0.28; 'correct': 0.28; 'chase': 0.29; 'case,': 0.29; 'convert': 0.29; 'becomes': 0.30; 'german': 0.32; "skip:' 20": 0.32; 'received:google.com': 0.34; 'text': 0.34; 'text.': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'characters': 0.36; 'stock': 0.36; 'anything': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'received:209.85.214': 0.39; 'where': 0.40; 'subject:-': 0.40; 'from:no real name:2**0': 0.60; 'information': 0.63; 'french': 0.64; 'erkl\xc3\xa4rung': 0.84; 'received:209.85.214.184': 0.84; 'received:mail- ob0-f184.google.com': 0.84 |
| Newsgroups | comp.lang.python |
| Date | Fri, 14 Sep 2012 09:15:25 -0700 (PDT) |
| In-Reply-To | <mailman.640.1347571498.27098.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=62.203.75.40; posting-account=ung4FAoAAAC46zhHJ0Nsnuox7M5gDvs_ |
| References | <mailman.640.1347571498.27098.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 62.203.75.40 |
| MIME-Version | 1.0 |
| Subject | Re: Least-lossy string.encode to us-ascii? |
| From | wxjmfauth@gmail.com |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | Python <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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.711.1347639335.27098.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347639335 news.xs4all.nl 6922 [2001:888:2000:d::a6]:49875 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:29177 |
Show key headers only | View raw
Le jeudi 13 septembre 2012 23:25:27 UTC+2, Tim Chase a écrit :
> 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. So
>
> "serviço móvil" becomes "servico movil". Is there anything stock
>
> that I've missed? I can do mystring.encode('us-ascii', 'replace')
>
> but that doesn't keep as much information as I'd hope.
>
Interesting case. It's where the coding of characters
meets characters usage, scripts, typography, linguistic
features.
I cann't discuss the Portugese case, but in French
and in German one way to achieve the task is to
convert the text in uppercases. It preserves a correct
text.
>>> s = 'Lætitia cœur éléphant français LUŸ Stoß Erklärung stören'
>>> libfrancais.SpecMajuscules(s)
'LAETITIA COEUR ELEPHANT FRANCAIS LUY STOSS ERKLAERUNG
STOEREN'
>>> r = 'LAETITIA COEUR ELEPHANT FRANCAIS LUY STOSS ERKLAERUNG STOEREN'
>>> r.encode('ascii', 'strict').decode('ascii', 'strict') == r
True
PS Avoid Py3.3 :-)
jmf
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Least-lossy string.encode to us-ascii? Tim Chase <python.list@tim.thechases.com> - 2012-09-13 16:26 -0500
Re: Least-lossy string.encode to us-ascii? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-14 03:49 +0000
Re: Least-lossy string.encode to us-ascii? wxjmfauth@gmail.com - 2012-09-14 09:15 -0700
Re: Least-lossy string.encode to us-ascii? Terry Reedy <tjreedy@udel.edu> - 2012-09-14 16:43 -0400
Re: Least-lossy string.encode to us-ascii? wxjmfauth@gmail.com - 2012-09-15 01:58 -0700
Re: Least-lossy string.encode to us-ascii? wxjmfauth@gmail.com - 2012-09-15 01:58 -0700
Re: Least-lossy string.encode to us-ascii? wxjmfauth@gmail.com - 2012-09-14 09:15 -0700
csiph-web