Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
12
Task/String-length/Ruby/string-length-7.rb
Normal file
12
Task/String-length/Ruby/string-length-7.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
class String
|
||||
# Define String#bytesize for Ruby 1.8.6.
|
||||
unless method_defined?(:bytesize)
|
||||
alias bytesize length
|
||||
end
|
||||
end
|
||||
|
||||
s = "文字化け"
|
||||
puts "Byte length: %d" % s.bytesize
|
||||
puts "Character length: %d" % s.gsub(/./u, ' ').size
|
||||
Loading…
Add table
Add a link
Reference in a new issue