471,328 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 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 2720
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

Post your reply

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

Similar topics

10 posts views Thread by Andrew Dalke | last post: by
2 posts views Thread by Xah Lee | last post: by
25 posts views Thread by Byte | last post: by
8 posts views Thread by sonald | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
reply views Thread by rosydwin | last post: by

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.