rom: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 9:35 AM
To: python-list@python.org
Subject: RE: ascii character - removing chars from string
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote:
> update...
>
> the error i'm g
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote:
> update...
>
> the error i'm getting...
>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in
> position 62: ordinal not in range(128)
Okay, now we're making progress -- we know what exception you're getting.
Now, how about t
-list@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
> i've done the s.replace('\xa0','') with no luck.
let me guess: you wrote
s.replace("\xa0", "")
instead of
s = s.replace("\xa0", ""
bruce wrote:
> i've done the s.replace('\xa0','') with no luck.
let me guess: you wrote
s.replace("\xa0", "")
instead of
s = s.replace("\xa0", "")
?
--
http://mail.python.org/mailman/listinfo/python-list
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 8:45 AM
To: python-list@python.org
Subject: RE: ascii character - removing chars from string
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote:
> simon...
i've done the s.replace('\xa0','') with no luck.
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 8:45 AM
To: python-list@python.org
Subject: RE: ascii character - removing cha
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote:
> simon...
>
> the issue that i'm seeing is not a result of simply using the
> 'string.replace' function. it appears that there's something else going on
> in the text
>
> although i can see the nbsp in the file, the file is manipulated by a n
andle non-ascii chars. i'm still looking for a way to search/replace
non-ascii chars...
this would/should resolve my issue..
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Simon Forman
Sent: Monday, July 03, 2006 11:28 PM
To: python-list@python.org
In <[EMAIL PROTECTED]>, bruce wrote:
> here is a sample of the text i'm looking to do hte search/replace for...
>
> bgcolor="#ff" > ACCT 209 - SURVEY OF ACCT PRIN
>
> i'm trying to figure out how to replace the " " with a ''. in html, the
> ' ' char is not a valid
ce
>
>
> -----Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf
> Of Simon Forman
> Sent: Monday, July 03, 2006 7:17 PM
> To: python-list@python.org
> Subject: Re: ascii character - removing chars from string
>
>
> bruce wrote:
> &g
n perl, i'd do 's / //' and be done with it!!!
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of bruce
Sent: Monday, July 03, 2006 8:26 PM
To: 'Simon Forman'
Cc: python-list@python.org
Subject: RE: ascii character - removing
L PROTECTED] Behalf
Of Simon Forman
Sent: Monday, July 03, 2006 7:17 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
> hi...
>
> update. i'm getting back html, and i'm getting strings like " foo "
> which is
bruce wrote:
> hi...
>
> update. i'm getting back html, and i'm getting strings like " foo "
> which is valid HTML as the ' ' is a space.
&, n, b, s, p, ; Those are all ascii characters.
> i need a way of stripping/removing the ' ' from the string
>
> the needs to be treated as a single char.
t;
ie ok_text = strip(text)
ok_text = "foo cat"
thanks
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Rune Strand
Sent: Monday, July 03, 2006 5:43 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
b
bruce wrote:
> hi...
>
> i'm running into a problem where i'm seeing non-ascii chars in the parsing
> i'm doing. in looking through various docs, i can't find functions to
> remove/restrict strings to valid ascii chars.
>
> i'm assuming python has something like
>
> valid_str = strip(invalid_str)
>
bruce wrote:
> hi...
>
> i'm running into a problem where i'm seeing non-ascii chars in the parsing
> i'm doing. in looking through various docs, i can't find functions to
> remove/restrict strings to valid ascii chars.
>
> i'm assuming python has something like
>
> valid_str = strip(invalid_str)
>
On 4/07/2006 9:27 AM, bruce wrote:
> hi...
>
> i'm running into a problem where i'm seeing non-ascii chars in the parsing
> i'm doing. in looking through various docs, i can't find functions to
> remove/restrict strings to valid ascii chars.
>
It's possible that you would be better off handling
bruce:
> valid_str = strip(invalid_str)
> where 'strip' removes/strips out the invalid chars...
This isn't short but it is fast:
import string
valid_chars = string.lowercase + string.uppercase + \
string.digits +
"""|!'\\"£$%&/()=?^*é§_:;>+,.-<\n \t"""
all_chars = "".join(map(
18 matches
Mail list logo