Get byte from a unicode string
$KCODE = "u" # Specify Unicode UTF-8, or start Ruby with -Ku option
require "jcode" # Load multibyte character support
mb = "2\303\2272=4" # This is "2×2=4" with a Unicode multiplication sign
mb.each_byte do |c| # Iterate through the bytes of the string.
print c, " " # c is Fixnum
end # Outputs "50 195 151 50 61 52 "
Related examples in the same category