Froze rails gems
[depot.git] / vendor / rails / activesupport / lib / active_support / core_ext / string / iterators.rb
diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
new file mode 100644 (file)
index 0000000..66a08a5
--- /dev/null
@@ -0,0 +1,21 @@
+require 'strscan'
+
+module ActiveSupport #:nodoc:
+  module CoreExtensions #:nodoc:
+    module String #:nodoc:
+      # Custom string iterators
+      module Iterators
+        def self.append_features(base)
+          super unless '1.9'.respond_to?(:each_char)
+        end
+
+        # Yields a single-character string for each character in the string.
+        # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
+        def each_char
+          scanner, char = StringScanner.new(self), /./mu
+          loop { yield(scanner.scan(char) || break) }
+        end
+      end
+    end
+  end
+end