DBの文字コードをShift-jisにする現状があるため、
取得した文字を UTF-8に変換することが必要。
参考サイトRubyist Magazine
Kconv というのを使うらしい
--- こんな感じ ------------------------------------------------------
require 'kconv'
str = 'Hello, るびま!' # 何かしらの文字コードの文字列
str_eucjp = str.toeuc # 文字コードを自動判定し、 EUC-JP に変換
str_shiftjis = str.tosjis # Shift_JIS に変換
str_iso2022jp = str.tojis # ISO-2022-JP (JIS) に変換
str_utf8 = str.toutf8 # UTF-8 に変換
---------------------------------------------------------------------
application_helper.rb に
def sconv(str)
require 'kconv'
str.toutf8
end
を追加しました。
sconvで変換できるようになりました
取得した文字を UTF-8に変換することが必要。
参考サイトRubyist Magazine
Kconv というのを使うらしい
--- こんな感じ ------------------------------------------------------
require 'kconv'
str = 'Hello, るびま!' # 何かしらの文字コードの文字列
str_eucjp = str.toeuc # 文字コードを自動判定し、 EUC-JP に変換
str_shiftjis = str.tosjis # Shift_JIS に変換
str_iso2022jp = str.tojis # ISO-2022-JP (JIS) に変換
str_utf8 = str.toutf8 # UTF-8 に変換
---------------------------------------------------------------------
application_helper.rb に
def sconv(str)
require 'kconv'
str.toutf8
end
を追加しました。
sconvで変換できるようになりました