Sha256: 0e01202881706663e3ad4994d2769c790d8baa786f1bc62e5e8c6c3f35b0bbf3

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

# -*- coding: utf-8 -*-
module Jpmobile::Mobile
  module UnicodeEmoticon
    # Jpmobile::Rack::Filter を適用する
    def apply_filter?
      Jpmobile.config.smart_phone_emoticon_compatibility
    end

    # Jpmobile::Rack::ParamsFilter を適用する
    def apply_params_filter?
      Jpmobile.config.smart_phone_emoticon_compatibility
    end

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

      [str, charset]
    end

    def unicode_emoticon?
      @request.user_agent.match(/ OS 5_/)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jpmobile-1.0.11 lib/jpmobile/mobile/unicode_emoticon.rb
jpmobile-2.0.10 lib/jpmobile/mobile/unicode_emoticon.rb
jpmobile-3.0.6 lib/jpmobile/mobile/unicode_emoticon.rb
jpmobile-1.0.10 lib/jpmobile/mobile/unicode_emoticon.rb
jpmobile-2.0.9 lib/jpmobile/mobile/unicode_emoticon.rb
jpmobile-3.0.5 lib/jpmobile/mobile/unicode_emoticon.rb