Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  48] [ 7]  / answers: 1 / hits: 18072  / 12 Years ago, thu, july 19, 2012, 12:00:00

I am trying to build a bookmarklet and got slammed with this issue which I was just able to figure out: a u8203 character, which Chrome unhelpfully tells me in my block of code (upon pasting into the JS console) is an `Invalid character ILLEGAL.



Luckily Safari was the one that told me it was a u8203.



I am editing the code in the Sublime Text 2 editor and somehow copying in and out of it (I also tried TextEdit) fails to remove it.



Is there some sort of website somewhere that will strip all characters other than ASCII?



When I try to save as ISO 8859 but it will save it back as UTF-8 because of unsupported characters.



... Yeah. that's the point. Get rid of my unsupported evil characters.



What am I supposed to do? Edit my file in a hex editor?



FYI I actually solved it by re-typing the code (which originated from this site by the way).


More From » unicode

 Answers
56

Well, the easiest way I can think of is to use sed



sed -i 's/[^[:print:]]//g' your_script.js
// ^^^^^ this can also be 'ascii'


or using tr



tr -cd '11121540-176' < old_script.js > new_script.js

[#84157] Wednesday, July 18, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hallie

Total Points: 503
Total Questions: 114
Total Answers: 103

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;