Permalink
Browse files

Merge pull request #2146 from dmathieu/blank_binary_encoding

fix String#blank? on binary strings
  • Loading branch information...
2 parents b8a4e9f + 0c58f39 commit af561901a0e4fb5585fd25a1cb3e76b6761c1e91 @fxn fxn committed Jul 20, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 activesupport/lib/active_support/core_ext/object/blank.rb
@@ -99,7 +99,12 @@ class String
# " something here ".blank? # => false
#
def blank?
- self !~ NON_WHITESPACE_REGEXP
+ # 1.8 does not takes [:space:] properly
+ if encoding_aware?
+ self !~ /[^[:space:]]/
+ else
+ self !~ NON_WHITESPACE_REGEXP
+ end
end
end

0 comments on commit af56190

Please sign in to comment.