Created
December 10, 2011 18:57
-
-
Save emartini/1455947 to your computer and use it in GitHub Desktop.
remove all non 127-ASCII chars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
# remove all non 127-ASCII chars | |
def remove_non_ascii | |
n=self.split("") | |
self.slice!(0..self.size) | |
n.each { |b| | |
if b[0].to_i< 33 || b[0].to_i>127 then | |
self.concat('') | |
else | |
self.concat(b) | |
end | |
} | |
self.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment