473,241 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Python string.endcode not replacing/ignoreing 0x8

I am working with data that is coming from a file, gets stored, abnd eventually gets pushed to an HTML page. I was having problems with unsupported characters in the HTML side so I figured I would eliminate the non-prinatble characters from my string. So I have:

value_encoded = cmd.encode ("ascii", "replace")

I have also used ignore (strict will throw an exception because of these characters). I would expect that the charcater code 0x8 would get caught by this and replaced/ignored but it does not, I guess its considered a valid ASCII character. Is there a way to remove the non-printable characters from the string?
Jun 25 '07 #1
2 2785
bartonc
6,596 Expert 4TB
I am working with data that is coming from a file, gets stored, abnd eventually gets pushed to an HTML page. I was having problems with unsupported characters in the HTML side so I figured I would eliminate the non-prinatble characters from my string. So I have:

value_encoded = cmd.encode ("ascii", "replace")

I have also used ignore (strict will throw an exception because of these characters). I would expect that the charcater code 0x8 would get caught by this and replaced/ignored but it does not, I guess its considered a valid ASCII character. Is there a way to remove the non-printable characters from the string?
Many tools have and escape() function which will return "\x08" which python can handle.
Jun 25 '07 #2
My concern is there will be other characters that cause my HTML page to fail to load. As it stands one tiny error and the whole page does not load. Any idea if there are other characters to be concerned with?
Jun 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
25
by: Byte | last post by:
I know this is probably a stupid question, but I'm learning Python, and am trying to get the if function to work with letters/words. Basicly, I'm trying to write a script that when run, says ...
8
by: sonald | last post by:
Hi, I am using python2.4.1 I need to pass russian text into python and validate the same. Can u plz guide me on how to make my existing code support the russian text. Is there any module...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 421 open ( +3) / 3530 closed ( +8) / 3951 total (+11) Bugs : 963 open ( +4) / 6426 closed (+21) / 7389 total (+25) RFE : 255 open...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.