Skip to content

Instantly share code, notes, and snippets.

@demimismo
Created October 28, 2008 14:54
Show Gist options
  • Save demimismo/20396 to your computer and use it in GitHub Desktop.
Save demimismo/20396 to your computer and use it in GitHub Desktop.
# convert multibyte strings to an url-safe encoding
class String
def to_permalink
(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv self).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment