Class | Jpmobile::Filter::Sjis |
In: |
lib/jpmobile/filter.rb
|
Parent: | Base |
Shift_JISとUnicodeのフィルタ(NKFを使用)
afterfilterを実行した後に実行する。
# File lib/jpmobile/filter.rb, line 78 78: def after_after(controller) 79: unless controller.response.body.blank? 80: # 500.htmlなどをUTF-8で書いたとき、docomoで文字化けするのを防ぐため 81: # response_bodyが空の場合はShift_JISを指定しない 82: controller.response.charset = "Shift_JIS" 83: end 84: end
to_internalを適用するべきかどうかを返す。
# File lib/jpmobile/filter.rb, line 86 86: def apply_incoming?(controller) 87: # Vodafone 3G/Softbank(Shift-JISにすると絵文字で不具合が生じる)以外の 88: # 携帯電話の場合に適用する。 89: mobile = controller.request.mobile 90: mobile && !(mobile.instance_of?(Jpmobile::Mobile::Vodafone)||mobile.instance_of?(Jpmobile::Mobile::Softbank)) 91: end
# File lib/jpmobile/filter.rb, line 92 92: def apply_outgoing?(controller) 93: [nil, "text/html", "application/xhtml+xml"].include?(controller.response.content_type) && 94: apply_incoming?(controller) 95: end
UTF-8からShift_JISに変換する。
# File lib/jpmobile/filter.rb, line 70 70: def to_external(str, controller) 71: NKF.nkf('-m0 -x -Ws', str) 72: end