Class Jpmobile::Filter::Sjis
In: lib/jpmobile/filter.rb
Parent: Base

Shift_JISとUnicodeのフィルタ(NKFを使用)

Methods

Public Instance methods

afterfilterを実行した後に実行する。

[Source]

    # File lib/jpmobile/filter.rb, line 71
71:       def after_after(controller)
72:         unless controller.response.body.blank?
73:           # 500.htmlなどをUTF-8で書いたとき、docomoで文字化けするのを防ぐため
74:           # response_bodyが空の場合はShift_JISを指定しない
75:           controller.response.charset = "Shift_JIS"
76:         end
77:       end

to_internalを適用するべきかどうかを返す。

[Source]

    # File lib/jpmobile/filter.rb, line 79
79:       def apply_incoming?(controller)
80:         # Vodafone 3G/Softbank(Shift-JISにすると絵文字で不具合が生じる)以外の
81:         # 携帯電話の場合に適用する。
82:         mobile = controller.request.mobile
83:         mobile && !(mobile.instance_of?(Jpmobile::Mobile::Vodafone)||mobile.instance_of?(Jpmobile::Mobile::Softbank))
84:       end

[Source]

    # File lib/jpmobile/filter.rb, line 85
85:       def apply_outgoing?(controller)
86:         [nil, "text/html", "application/xhtml+xml"].include?(controller.response.content_type) &&
87:           apply_incoming?(controller)
88:       end

UTF-8からShift_JISに変換する。

[Source]

    # File lib/jpmobile/filter.rb, line 63
63:       def to_external(str, controller)
64:         NKF.nkf('-m0 -x -Ws', str)
65:       end

Shift_JISからUTF-8に変換する。

[Source]

    # File lib/jpmobile/filter.rb, line 67
67:       def to_internal(str, controller)
68:         NKF.nkf('-m0 -x -Sw', str)
69:       end

[Validate]