diff options
author | Akira Matsuda <ronnie@dio.jp> | 2011-07-13 20:30:34 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2011-07-14 07:48:39 +0900 |
commit | 9c60860322d58e1a2fcd42f1a21ec86ec2caa50b (patch) | |
tree | 81f16658ab43a8235031cba10dc0e6a030e7d3b4 /activesupport/lib | |
parent | 704ee0df65b6ae9f39bbd4c7b3ed697a4039efd8 (diff) | |
download | rails-9c60860322d58e1a2fcd42f1a21ec86ec2caa50b.tar.gz rails-9c60860322d58e1a2fcd42f1a21ec86ec2caa50b.tar.bz2 rails-9c60860322d58e1a2fcd42f1a21ec86ec2caa50b.zip |
treat fullwidth whitespace as a blank character
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/blank.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 8221dc4abe..677ec1141d 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -86,14 +86,18 @@ class Hash end class String + # 0x3000: fullwidth whitespace + NON_WHITESPACE_REGEXP = %r![^\s#{[0x3000].pack("U")}]! + # A string is blank if it's empty or contains whitespaces only: # # "".blank? # => true # " ".blank? # => true + # " ".blank? # => true # " something here ".blank? # => false # def blank? - self !~ /\S/ + self !~ NON_WHITESPACE_REGEXP end end |