Skip to content

Commit

Permalink
Use native downcase and upcase
Browse files Browse the repository at this point in the history
If another library has overridden these methods to fold the case of
characters outside the ASCII range then the user will get back something
closer to what he or she expects.
  • Loading branch information
norman committed Jan 2, 2015
1 parent f4a1d49 commit 5310aa9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/babosa/utf8/dumb_proxy.rb
Expand Up @@ -14,14 +14,13 @@ module DumbProxy
extend self

def downcase(string)
string.unpack("U*").map {|char| Mappings::DOWNCASE[char] or char}.flatten.pack("U*")
string.downcase.unpack("U*").map {|char| Mappings::DOWNCASE[char] or char}.flatten.pack("U*")
end

def upcase(string)
string.unpack("U*").map {|char| Mappings::UPCASE[char] or char}.flatten.pack("U*")
string.upcase.unpack("U*").map {|char| Mappings::UPCASE[char] or char}.flatten.pack("U*")
end


if String.public_instance_methods.include?(:unicode_normalize)
def normalize_utf8(string)
string.unicode_normalize
Expand Down

0 comments on commit 5310aa9

Please sign in to comment.