Module: Jpmobile::Mobile::UnicodeEmoticon

Included in:
Ipad, Iphone
Defined in:
lib/jpmobile/mobile/unicode_emoticon.rb

Instance Method Summary collapse

Instance Method Details

#apply_filter?Boolean

Jpmobile::Filter を適用する

Returns:

  • (Boolean)


4
5
6
# File 'lib/jpmobile/mobile/unicode_emoticon.rb', line 4

def apply_filter?
  Jpmobile.config.smart_phone_emoticon_compatibility
end

#apply_params_filter?Boolean

Jpmobile::ParamsFilter を適用する

Returns:

  • (Boolean)


9
10
11
# File 'lib/jpmobile/mobile/unicode_emoticon.rb', line 9

def apply_params_filter?
  Jpmobile.config.smart_phone_emoticon_compatibility
end

#to_external(str, content_type, charset) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jpmobile/mobile/unicode_emoticon.rb', line 26

def to_external(str, content_type, charset)
  # UTF-8を数値参照に
  str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
  str = if unicode_emoticon?
          Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)
        else
          # 数値参照を絵文字コードに変換
          Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, false)
        end

  [str, charset]
end

#to_internal(str) ⇒ Object

文字コード変換



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jpmobile/mobile/unicode_emoticon.rb', line 14

def to_internal(str)
  str = if unicode_emoticon?
          # Unicode絵文字を数値参照に変換
          Jpmobile::Emoticon.external_to_unicodecr_unicode60(Jpmobile::Util.utf8(str))
        else
          # SoftBank絵文字を数値参照に変換
          Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str))
        end
  # 数値参照を UTF-8 に変換
  Jpmobile::Emoticon.unicodecr_to_utf8(str)
end

#unicode_emoticon?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/jpmobile/mobile/unicode_emoticon.rb', line 39

def unicode_emoticon?
  @request.user_agent.match(/ OS (\d)_/) and Regexp.last_match(1).to_i >= 5
end