Re: Is there a string function to trim all non-ascii characters out of a string
- From: Dan Bishop <danb_83@xxxxxxxxx>
- Date: Mon, 31 Dec 2007 00:54:05 -0800 (PST)
On Dec 31, 2:20 am, "silverburgh.me...@xxxxxxxxx"
<silverburgh.me...@xxxxxxxxx> wrote:
Hi,
Is there a string function to trim all non-ascii characters out of a
string?
Let say I have a string in python (which is utf8 encoded), is there a
python function which I can convert that to a string which composed of
only ascii characters?
Thank you.
def ascii_chars(string):
return ''.join(char for char in string if ord(char) < 128)
.
- References:
- Is there a string function to trim all non-ascii characters out of a string
- From: silverburgh.meryl@xxxxxxxxx
- Is there a string function to trim all non-ascii characters out of a string
- Prev by Date: Re: Tab indentions on different platforms?
- Next by Date: Re: Is there a string function to trim all non-ascii characters out of a string
- Previous by thread: Is there a string function to trim all non-ascii characters out of a string
- Next by thread: Re: Is there a string function to trim all non-ascii characters out of a string
- Index(es):
Relevant Pages
|