diff --git a/activesupport/lib/active_support/multibyte/utils.rb b/activesupport/lib/active_support/multibyte/utils.rb index acef84d..6e71b79 100644 --- a/activesupport/lib/active_support/multibyte/utils.rb +++ b/activesupport/lib/active_support/multibyte/utils.rb @@ -26,11 +26,11 @@ module ActiveSupport #:nodoc: else def self.verify(string) if expression = valid_character - for c in string.split(//) - return false unless valid_character.match(c) - end + # note: split(//) will split on Unicode characters if $KCODE='UTF8' + string.split(//).all? {|c| expression.match(c)} + else + true end - true end end @@ -49,13 +49,12 @@ module ActiveSupport #:nodoc: else def self.clean(string) if expression = valid_character - stripped = []; for c in string.split(//) - stripped << c if valid_character.match(c) - end; stripped.join + # note: split(//) will split on Unicode characters if $KCODE='UTF8' + string.split(//).grep(expression).join else string end end end end -end \ No newline at end of file +end