Last active
December 26, 2016 16:28
-
-
Save kirkgo/b587d9baf55e95667595 to your computer and use it in GitHub Desktop.
Change the upcase and downcase method of the ruby String class to handle the change of accented upper and lower case letters.
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 | |
alias_method :old_upcase, :upcase | |
def upcase | |
self.gsub( /\303[\240-\277]/ ) do |match| | |
match[0].chr + (match[1] - 040).chr | |
end.old_upcase | |
end | |
alias_method :old_downcase, :downcase | |
def downcase | |
self.gsub( /\303[\200-\237]/ ) do |match| | |
match[0].chr + (match[1] + 040).chr | |
end.old_downcase | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment