aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/multibyte/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/multibyte/utils.rb')
-rw-r--r--activesupport/lib/active_support/multibyte/utils.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/multibyte/utils.rb b/activesupport/lib/active_support/multibyte/utils.rb
index 8e47763d39..b243df46d8 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 expression.match(c)
- end
+ # Splits the string on character boundaries, which are determined based on $KCODE.
+ string.split(//).all? { |c| expression.match(c) }
+ else
+ true
end
- true
end
end
@@ -49,9 +49,8 @@ module ActiveSupport #:nodoc:
else
def self.clean(string)
if expression = valid_character
- stripped = []; for c in string.split(//)
- stripped << c if expression.match(c)
- end; stripped.join
+ # Splits the string on character boundaries, which are determined based on $KCODE.
+ string.split(//).grep(expression).join
else
string
end