This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -0,0 +1 @@
length("Hello, World!")

View file

@ -0,0 +1 @@
(define str "J\u0332o\u0332s\u0332e\u0301\u0332")

View file

@ -0,0 +1,2 @@
-> (printf "str has ~a characters" (string-length str))
str has 9 characters

View file

@ -0,0 +1,2 @@
-> (printf "str has ~a bytes in utf-8" (bytes-length (string->bytes/utf-8 str)))
str has 14 bytes in utf-8

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
puts "あいうえお".bytesize
# => 15

View file

@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
puts "あいうえお".length
# => 5
puts "あいうえお".size # alias for length
# => 5

View file

@ -0,0 +1,4 @@
# -*- coding: iso-8859-1 -*-
s = "møøse"
puts "Byte length: %d" % s.bytesize
puts "Character length: %d" % s.length

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
s = "møøse"
puts "Byte length: %d" % s.bytesize
puts "Character length: %d" % s.length

View file

@ -0,0 +1,4 @@
# -*- coding: gb18030 -*-
s = "møøse"
puts "Byte length: %d" % s.bytesize
puts "Character length: %d" % s.length

View 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

View file

@ -0,0 +1,2 @@
input a$
print len(a$)