Get the position of the first multibyte char
$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.mbchar? # => 1: position of the first multibyte char, or nil
Related examples in the same category