Class: Emoticon::Transcoder::Jphone
- Inherits:
-
Softbank
- Object
- Emoticon::Transcoder
- Softbank
- Emoticon::Transcoder::Jphone
- Defined in:
- lib/emoticon/transcoder/jphone.rb
Constant Summary
Constants inherited from Emoticon::Transcoder
Constants included from ConversionTable
ConversionTable::AU_EMAILJIS_TO_UNICODE, ConversionTable::AU_SJIS_REGEXP, ConversionTable::AU_SJIS_TO_UNICODE, ConversionTable::AU_UNICODE_TO_SJIS, ConversionTable::CONVERSION_TABLE_TO_AU, ConversionTable::CONVERSION_TABLE_TO_DOCOMO, ConversionTable::CONVERSION_TABLE_TO_SOFTBANK, ConversionTable::DOCOMO_SJIS_REGEXP, ConversionTable::DOCOMO_SJIS_TO_UNICODE, ConversionTable::DOCOMO_UNICODE_TO_SJIS, ConversionTable::EMOTICON_UNICODES, ConversionTable::SJIS_REGEXP, ConversionTable::SJIS_TO_UNICODE, ConversionTable::SOFTBANK_UNICODE_REGEXP, ConversionTable::SOFTBANK_UNICODE_TO_WEBCODE, ConversionTable::SOFTBANK_WEBCODE_REGEXP, ConversionTable::SOFTBANK_WEBCODE_TO_UNICODE, ConversionTable::UNICODE_TO_SJIS, ConversionTable::UTF8_REGEXP
Instance Method Summary collapse
-
#external_to_unicodecr(str) ⇒ Object
str
のなかでWebcodeのSoftBank絵文字を(+0x1000だけシフトして)Unicode数値文字参照に変換した文字列を返す。.
Methods inherited from Emoticon::Transcoder
#internal_to_external, #unicodecr_to_external, #unicodecr_to_utf8, #utf8_to_unicodecr
Instance Method Details
#external_to_unicodecr(str) ⇒ Object
str
のなかでWebcodeのSoftBank絵文字を(+0x1000だけシフトして)Unicode数値文字参照に変換した文字列を返す。
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/emoticon/transcoder/jphone.rb', line 5 def external_to_unicodecr(str) # SoftBank Webcode s = str.clone # 連続したエスケープコードが省略されている場合は切りはなす。 s.gsub!(/\x1b\x24(.)(.+?)\x0f/) do |match| a = $1 $2.split(//).map{|x| "\x1b\x24#{a}#{x}\x0f"}.join('') end # Webcodeを変換 s.gsub(SOFTBANK_WEBCODE_REGEXP) do |match| unicode = SOFTBANK_WEBCODE_TO_UNICODE[match[2,2]] + 0x1000 unicode ? ("&#x%04x;"%unicode) : match end end |