RE: ascii character - removing chars from string

2006-07-04 Thread bruce
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

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
-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", ""

Re: ascii character - removing chars from string

2006-07-04 Thread Fredrik Lundh
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

RE: ascii character - removing chars from string

2006-07-04 Thread 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 chars from string On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote: > simon...

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
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

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
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

RE: ascii character - removing chars from string update

2006-07-03 Thread Marc 'BlackJack' Rintsch
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

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
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

RE: ascii character - removing chars from string update

2006-07-03 Thread bruce
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

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
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

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
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.

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
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

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
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) >

Re: ascii character - removing chars from string

2006-07-03 Thread Rune Strand
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) >

Re: ascii character - removing chars from string

2006-07-03 Thread John Machin
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

Re: ascii character - removing chars from string

2006-07-03 Thread bearophileHUGS
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(