Programming Ruby multibyte String

s="2×2=4"
p s.bytesize #=>6
s.bytesize.times{|i| print s.getbyte(i)," "} #=> 50,195,151,50,61,52
puts "\n"
p s.length #=>5

s.length.times{|i| print s[i], " "} #=>2 × 2 = 4

s.setbyte(5,s.getbyte(5)+1) #s is now "2×2=5"
s.length.times{|i| print s[i], " "}

p s.encoding #=>

euro1="\u20AC"
puts euro1 #=>€
p euro1.encoding #=> #
p euro1.bytesize #=> 3

euro2=euro1.encode("iso-8859-15")
puts euro2.inspect #=>\xA4
p euro2.encoding #=> #
p euro2.bytesize #=> 1

euro3=euro2.encode("utf-8") #=> true
if euro1==euro3
puts "true"
else
puts "false"
end


#transcode to UTF-8
byte="\xA4"
char=byte.encode("utf-8","iso-8859-15")
puts char #=>€
p char.encoding #=> #