Skip to content

Instantly share code, notes, and snippets.

@emartini
Created December 10, 2011 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emartini/1455947 to your computer and use it in GitHub Desktop.
Save emartini/1455947 to your computer and use it in GitHub Desktop.
remove all non 127-ASCII chars
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