Check the string encoding : encoding « String « Ruby
- Ruby
- String
- encoding
Check the string encoding
# -*- coding: utf-8 -*-
s = "2×2=4" # Note multibyte multiplication character
s.encoding # => <Encoding: UTF-8>
t = "2+2=4" # All characters are in the ASCII subset of UTF-8
t.encoding # => <Encoding: ASCII-8BIT>
Related examples in the same category