Specify Unicode UTF-8, or start Ruby with -Ku option
$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
puts mb.length
puts mb.jlength # => 5: but only 5 characters
Related examples in the same category