aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJason Cheow <jfh7crw02@sneakemail.com>2008-11-26 22:16:28 +0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-12-08 16:02:57 -0800
commit4e60eebae05aeec65e4894e3901c9d61c9b32910 (patch)
tree45cc75a790161a76c55da6db97a69cea56f95c42 /activesupport/lib
parent9b22e56d89a55460a18d5f38adf9fee919f52266 (diff)
downloadrails-4e60eebae05aeec65e4894e3901c9d61c9b32910.tar.gz
rails-4e60eebae05aeec65e4894e3901c9d61c9b32910.tar.bz2
rails-4e60eebae05aeec65e4894e3901c9d61c9b32910.zip
Add ActiveSupport::Multibyte::Chars#ord method so that it returns correct Unicode value instead of falling back on String#ord in CoreExtensions, which is not multibyte compatible
[#1483 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index be9c6d3567..a00b165222 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -344,6 +344,14 @@ module ActiveSupport #:nodoc:
end
alias_method :[], :slice
+ # Converts first character in the string to Unicode value
+ #
+ # Example:
+ # 'こんにちは'.mb_chars.ord #=> 12371
+ def ord
+ self.class.u_unpack(@wrapped_string)[0]
+ end
+
# Convert characters in the string to uppercase.
#
# Example: