Skip to content

Instantly share code, notes, and snippets.

@maraigue
Created October 16, 2009 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maraigue/211478 to your computer and use it in GitHub Desktop.
Save maraigue/211478 to your computer and use it in GitHub Desktop.
# A patch that let strings
# * return number of characters by String#jlength
# * return number of bytes by String#bytesize
# regardless of Ruby version
#
# by H.Hiro(Maraigue)
# main@hhiro.net
if RUBY_VERSION >= "1.9.0"
class String
alias :jlength :length
end
else
require "jcode"
class String
alias :bytesize :length
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment