Skip to content

Commit

Permalink
this is the answer to [ruby-dev:40532].
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkn committed Mar 3, 2010
1 parent 3db524e commit ff24598
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
4 changes: 2 additions & 2 deletions enc/trans/emoji_sjis_docomo.trans
@@ -1,7 +1,7 @@
#include "transcode_data.h"

<%
transcode_tblgen "Shift_JIS-DOCOMO", "UTF8-DOCOMO",
transcode_tblgen "SJIS-DOCOMO", "UTF8-DOCOMO",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "JISX0201-KANA/UCS") +
citrus_decode_mapsrc("mskanji", 2, %w(EMOJI_SHIFT_JIS-DOCOMO/UCS
Expand All @@ -11,7 +11,7 @@
CP932UDA/UCS
JISX0208:MS/UCS).join(","))

transcode_tblgen "UTF8-DOCOMO", "Shift_JIS-DOCOMO",
transcode_tblgen "UTF8-DOCOMO", "SJIS-DOCOMO",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "UCS/JISX0201-KANA") +
citrus_decode_mapsrc("mskanji", 2, %w(UCS/EMOJI_SHIFT_JIS-DOCOMO
Expand Down
4 changes: 2 additions & 2 deletions enc/trans/emoji_sjis_kddi.trans
@@ -1,7 +1,7 @@
#include "transcode_data.h"

<%
transcode_tblgen "Shift_JIS-KDDI", "UTF8-KDDI",
transcode_tblgen "SJIS-KDDI", "UTF8-KDDI",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "JISX0201-KANA/UCS") +
citrus_decode_mapsrc("mskanji", 2, %w(EMOJI_SHIFT_JIS-KDDI/UCS
Expand All @@ -11,7 +11,7 @@
CP932UDA/UCS
JISX0208:MS/UCS).join(","))

transcode_tblgen "UTF8-KDDI", "Shift_JIS-KDDI",
transcode_tblgen "UTF8-KDDI", "SJIS-KDDI",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "UCS/JISX0201-KANA") +
citrus_decode_mapsrc("mskanji", 2, %w(UCS/EMOJI_SHIFT_JIS-KDDI
Expand Down
4 changes: 2 additions & 2 deletions enc/trans/emoji_sjis_softbank.trans
@@ -1,7 +1,7 @@
#include "transcode_data.h"

<%
transcode_tblgen "Shift_JIS-SoftBank", "UTF8-SoftBank",
transcode_tblgen "SJIS-SoftBank", "UTF8-SoftBank",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "JISX0201-KANA/UCS") +
citrus_decode_mapsrc("mskanji", 2, %w(EMOJI_SHIFT_JIS-SOFTBANK/UCS
Expand All @@ -11,7 +11,7 @@
CP932UDA/UCS
JISX0208:MS/UCS).join(","))

transcode_tblgen "UTF8-SoftBank", "Shift_JIS-SoftBank",
transcode_tblgen "UTF8-SoftBank", "SJIS-SoftBank",
[["{00-7f}", :nomap]] +
citrus_decode_mapsrc("mskanji", 1, "UCS/JISX0201-KANA") +
citrus_decode_mapsrc("mskanji", 2, %w(UCS/EMOJI_SHIFT_JIS-SOFTBANK
Expand Down
30 changes: 24 additions & 6 deletions enc/x-emoji.c
@@ -1,14 +1,32 @@
#include "regint.h"

/*
* Name: UTF8-Google
* Link: http://www.unicode.org/~scherer/emoji4unicode/snapshot/full.html
*/
ENC_REPLICATE("UTF8-Google", "UTF-8")

/*
* Name: UTF8-DoCoMo, SJIS-DoCoMo
* Link: http://www.nttdocomo.co.jp/english/service/imode/make/content/pictograph/basic/index.html
* Link: http://www.nttdocomo.co.jp/english/service/imode/make/content/pictograph/extention/index.html
*/
ENC_REPLICATE("UTF8-DoCoMo", "UTF-8")
ENC_REPLICATE("UTF8-KDDI", "UTF-8")
ENC_REPLICATE("UTF8-SoftBank", "UTF-8")

ENC_REPLICATE("Shift_JIS-DoCoMo", "Windows-31J")
ENC_REPLICATE("Shift_JIS-KDDI", "Windows-31J")
ENC_REPLICATE("Shift_JIS-SoftBank", "Windows-31J")
ENC_REPLICATE("SJIS-DoCoMo", "Windows-31J")

/*
* Name: UTF8-KDDI, SJIS-KDDI, ISO-2022-JP-KDDI
* Link: http://www.au.kddi.com/ezfactory/tec/spec/img/typeD.pdf
*/
ENC_REPLICATE("UTF8-KDDI", "UTF-8")
ENC_REPLICATE("SJIS-KDDI", "Windows-31J")
ENC_REPLICATE("ISO-2022-JP-KDDI", "ISO-2022-JP")
ENC_REPLICATE("stateless-ISO-2022-JP-KDDI", "stateless-ISO-2022-JP")

/*
* Name: UTF8-SoftBank, SJIS-SoftBank
* Link: http://creation.mb.softbank.jp/web/web_pic_about.html
* Link: http://www2.developers.softbankmobile.co.jp/dp/tool_dl/download.php?docid=120&companyid=
*/
ENC_REPLICATE("UTF8-SoftBank", "UTF-8")
ENC_REPLICATE("SJIS-SoftBank", "Windows-31J")
32 changes: 20 additions & 12 deletions test/ruby/enc/test_emoji.rb
@@ -1,5 +1,13 @@
require 'test/unit'

class TestRenameSJIS < Test::Unit::TestCase
def test_shift_jis
assert_raise(ArgumentError) { "".force_encoding("Shift_JIS-DoCoMo") }
assert_raise(ArgumentError) { "".force_encoding("Shift_JIS-KDDI") }
assert_raise(ArgumentError) { "".force_encoding("Shift_JIS-SoftBank") }
end
end

class TestUTF8_BLACK_SUN_WITH_RAYS < Test::Unit::TestCase
def setup
@codes = {
Expand Down Expand Up @@ -53,14 +61,14 @@ def setup

def test_encoding_name
%w(UTF8-DoCoMo
Shift_JIS-DoCoMo).each do |n|
SJIS-DoCoMo).each do |n|
assert Encoding.name_list.include?(n), "encoding not found: #{n}"
end
end

def test_comparison
assert_not_equal Encoding::UTF_8, Encoding::UTF8_DoCoMo
assert_not_equal Encoding::Windows_31J, Encoding::Shift_JIS_DoCoMo
assert_not_equal Encoding::Windows_31J, Encoding::SJIS_DoCoMo
end

def test_from_utf8
Expand Down Expand Up @@ -141,7 +149,7 @@ def setup

def test_encoding_name
%w(UTF8-KDDI
Shift_JIS-KDDI
SJIS-KDDI
ISO-2022-JP-KDDI
stateless-ISO-2022-JP-KDDI).each do |n|
assert Encoding.name_list.include?(n), "encoding not found: #{n}"
Expand All @@ -150,7 +158,7 @@ def test_encoding_name

def test_comparison
assert_not_equal Encoding::UTF_8, Encoding::UTF8_KDDI
assert_not_equal Encoding::Windows_31J, Encoding::Shift_JIS_KDDI
assert_not_equal Encoding::Windows_31J, Encoding::SJIS_KDDI
assert_not_equal Encoding::ISO_2022_JP, Encoding::ISO_2022_JP_KDDI
assert_not_equal Encoding::Stateless_ISO_2022_JP, Encoding::Stateless_ISO_2022_JP_KDDI
end
Expand Down Expand Up @@ -277,14 +285,14 @@ def setup

def test_encoding_name
%w(UTF8-SoftBank
Shift_JIS-SoftBank).each do |n|
SJIS-SoftBank).each do |n|
assert Encoding.name_list.include?(n), "encoding not found: #{n}"
end
end

def test_comparison
assert_not_equal Encoding::UTF_8, Encoding::UTF8_SoftBank
assert_not_equal Encoding::Windows_31J, Encoding::Shift_JIS_SoftBank
assert_not_equal Encoding::Windows_31J, Encoding::SJIS_SoftBank
end

def test_from_utf8
Expand Down Expand Up @@ -446,27 +454,27 @@ def to_utf8_softbank(str)
end

def sjis_docomo(str)
str.force_encoding("Shift_JIS-DoCoMo")
str.force_encoding("SJIS-DoCoMo")
end

def to_sjis_docomo(str)
str.encode("Shift_JIS-DoCoMo")
str.encode("SJIS-DoCoMo")
end

def sjis_kddi(str)
str.force_encoding("Shift_JIS-KDDI")
str.force_encoding("SJIS-KDDI")
end

def to_sjis_kddi(str)
str.encode("Shift_JIS-KDDI")
str.encode("SJIS-KDDI")
end

def sjis_softbank(str)
str.force_encoding("Shift_JIS-SoftBank")
str.force_encoding("SJIS-SoftBank")
end

def to_sjis_softbank(str)
str.encode("Shift_JIS-SoftBank")
str.encode("SJIS-SoftBank")
end

def iso2022jp_kddi(str)
Expand Down

0 comments on commit ff24598

Please sign in to comment.