jpmobileã使ã£ã¦ãau/softbankã§ããcontrollerå ã§ããã³ã¢çµµæåã«ãããã³ã°æ¸ã¿ã®utf8å¤ãå¾ãæ¹æ³
é常ã«ãããã«ããã¿ã¤ãã«ã§ããã
ã¦ã¼ã¶ãããã¹ããã©ã¼ã ã«çµµæåãå
¥ãã¦éã£ã¦ããã¨ãã®è©±ãã§ãã
以ä¸ã®ãããªã³ã¼ãããã£ãéã«ã
class HogeController < ApplicationController mobile_filter def hoge # ä¾ãã°ããã³ã¢ã®ãæ´ããã«å¯¾å¿ããçµµæåã¯ãjpmobileã® # before_filterãéã£ããactionã®æç¹ã§ã # docomo : \xEE\x98\xBE # au : \xEE\x92\x88 # softbank : \xEF\x81\x8A # ã¨ãªã£ã¦ãã end end
ãã®ã¾ã¾hogeã¢ã¯ã·ã§ã³ã®viewã§è¡¨ç¤ºãããªããjpmobileã®after_filterãããã£ã¦ã
docomo : \xF8\x9F (sjis)
au : \xF8\x9F (sjis)
softbank : \xEE\x98\xBE (utf8)
ã«ãªãã®ã§ãããhogeã¢ã¯ã·ã§ã³ã®ä¸ã§ãau/softbankã§ãdocomoã®å¤ãæã«å ¥ããã«ã¯ã©ããããããã§ããããã
ä¸å¿ãä¸è¨ã®æ¹æ³ã§æã«å ¥ãããã¨ãåºæ¥ãã®ã§ãã¡ã¢ã£ã¦ããã¾ãã
class HogeController < ApplicationController mobile_filter def hoge # strãå¤æãããæååã¨ãã㨠str = Jpmobile::Emoticon::utf8_to_unicodecr(str) str = Jpmobile::Emoticon::unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, false) # ãã㧠str㯠# docomo : \xEE\x98\xBE # au : \xEE\x98\xBE # softbank : \xEE\x98\xBE # ã¨ãªãã¾ã end end
åç´ã«ãjpmobileã®after_filterãããã¦ããã ãã§ããã
unicodecr_to_externalã®3ã¤ç®ã®å¼æ°ãfalseã«ãã¦utf8-->sjiså¤æãè¡ãªããªãããã«ãã¦ãã¾ã