Created
May 24, 2010 06:43
-
-
Save stefanluptak/411597 to your computer and use it in GitHub Desktop.
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 | |
# "Příšerně žluťoučký kůň úpěl ďábelské ódy".strip_diacritics => | |
# "Priserne zlutoucky kun upel dabelske ody" | |
def strip_diacritics | |
self.mb_chars.normalize(:kd).to_s.gsub(/[^\x00-\x7F]/, '') | |
end | |
# Little hacks to allow using also decimal comma (used in EU) not only decimal point | |
# "3,75".to_d => 3.75 | |
# "3,75".to_f => 3.75 | |
alias_method :original_to_d, :to_d | |
def to_d | |
gsub(/,/, ".").original_to_d | |
end | |
alias_method :original_to_f, :to_f | |
def to_f | |
gsub(/,/, ".").original_to_f | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment