'いろはに'.encoding str = 'こんにちは' p str.encoding p new_str = str.encode(Encoding::EUC_JP) new_str.encoding str = "こんにちは" p str.encoding p str.encode!(Encoding::EUC_JP) str.encoding utf8 = 'こんにちは'.encode('UTF-8') eucjp = 'こんにちは'.encode('EUC-JP') p utf8 == eucjp utf8.eql?(eucjp) utf8 + eucjp eucjp = 'Hello'.encode('EUC-JP') utf8 = 'Hello'.encode('UTF-8') utf16 = 'Hello'.encode('UTF-16') #non ascii compat ascii = 'Hello'.encode('ASCII-8BIT') p utf8 == eucjp p utf8 == utf16 (utf8 + eucjp).encoding (eucjp + utf8).encoding utf8 + utf16