Ruby 3.1.3、Rails 6.0.6で実装した際の話です。 irb(main):009:0> str = NKF.nkf('-x --ic=UTF-8 --oc=Shift_JIS', 'オオモリ') => "\xB5\xB5\xD3\xD8" irb(main):010:0> str.force_encoding('UTF-8') => "\xB5\xB5\xD3\xD8" irb(main):011:0> str = NKF.nkf('-x --oc=Shift_JIS', str) => "\x{8B54}\x{9A77}" irb(main):012:0> NKF.nkf('-x --ic=Shift_JIS --oc=UTF-8', str) => "亀嗹" NKFの--ic オプションは入力エンコーディング、--ocオプションは出力エンコーディング。 上記ではStrin