maraigue (owner)

Revisions

gist: 211478 Download_button fork
public
Public Clone URL: git://gist.github.com/211478.git
Embed All Files: show embed
strlen.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 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