スマホで絵文字を入力して作成した発言もemojioneフォントで表示されるようにした
This commit is contained in:
parent
b885c6bf66
commit
6689da0bb3
|
@ -1,20 +1,31 @@
|
|||
package jp.juggler.subwaytooter.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class EmojiMap {
|
||||
public static final HashMap<String, String> _shortNameToUnicode = new HashMap<String, String>();
|
||||
public static final HashMap<String, String> _unicodeToShortName = new HashMap<String, String>();
|
||||
public static final HashMap< String, String > _shortNameToUnicode = new HashMap<>();
|
||||
public static final HashSet< String > _unicode_set = new HashSet<>();
|
||||
|
||||
static int max_length = 0;
|
||||
|
||||
private static void _addEntry( String name, String utf16 ){
|
||||
|
||||
// ショートネームからunicodeへの変換マップ
|
||||
_shortNameToUnicode.put( name, utf16 );
|
||||
|
||||
private static void _addEntry(String name,String unicode){
|
||||
_shortNameToUnicode.put(name,unicode);
|
||||
int c = unicode.charAt( 0 );
|
||||
if( unicode.length() == 1 && 0 <= c && c <= 0x7f ){
|
||||
// ASCII文字列は絵文字とみなさない
|
||||
}else{
|
||||
// 他は絵文字フォントで囲いたい
|
||||
_unicodeToShortName.put(unicode,name);
|
||||
int c = utf16.charAt( 0 );
|
||||
if( utf16.length() == 1 && 0 <= c && c <= 0x7f ){
|
||||
return;
|
||||
}
|
||||
|
||||
// 絵文字のUTF-16表現の最大長
|
||||
if( utf16.length() > max_length ){
|
||||
max_length = utf16.length();
|
||||
}
|
||||
// 集合を覚えておく
|
||||
_unicode_set.add( utf16 );
|
||||
}
|
||||
|
||||
private static void init1(){
|
||||
|
@ -120,6 +131,7 @@ public class EmojiMap {
|
|||
_addEntry( "baby_symbol", new String( new int[]{ 0x1f6bc }, 0, 1 ) );
|
||||
_addEntry( "baby_tone1", new String( new int[]{ 0x1f476, 0x1f3fb }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init2(){
|
||||
_addEntry( "baby_tone2", new String( new int[]{ 0x1f476, 0x1f3fc }, 0, 2 ) );
|
||||
_addEntry( "baby_tone3", new String( new int[]{ 0x1f476, 0x1f3fd }, 0, 2 ) );
|
||||
|
@ -223,6 +235,7 @@ public class EmojiMap {
|
|||
_addEntry( "blond-haired_woman_light_skin_tone", new String( new int[]{ 0x1f471, 0x1f3fb, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "blond-haired_woman_medium_dark_skin_tone", new String( new int[]{ 0x1f471, 0x1f3fe, 0x2640 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init3(){
|
||||
_addEntry( "blond-haired_woman_medium_light_skin_tone", new String( new int[]{ 0x1f471, 0x1f3fc, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "blond-haired_woman_medium_skin_tone", new String( new int[]{ 0x1f471, 0x1f3fd, 0x2640 }, 0, 3 ) );
|
||||
|
@ -326,6 +339,7 @@ public class EmojiMap {
|
|||
_addEntry( "capricorn", new String( new int[]{ 0x2651 }, 0, 1 ) );
|
||||
_addEntry( "card_box", new String( new int[]{ 0x1f5c3 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init4(){
|
||||
_addEntry( "card_file_box", new String( new int[]{ 0x1f5c3 }, 0, 1 ) );
|
||||
_addEntry( "card_index", new String( new int[]{ 0x1f4c7 }, 0, 1 ) );
|
||||
|
@ -429,6 +443,7 @@ public class EmojiMap {
|
|||
_addEntry( "cocktail", new String( new int[]{ 0x1f378 }, 0, 1 ) );
|
||||
_addEntry( "coffee", new String( new int[]{ 0x2615 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init5(){
|
||||
_addEntry( "coffin", new String( new int[]{ 0x26b0 }, 0, 1 ) );
|
||||
_addEntry( "cold_sweat", new String( new int[]{ 0x1f630 }, 0, 1 ) );
|
||||
|
@ -532,6 +547,7 @@ public class EmojiMap {
|
|||
_addEntry( "desktop", new String( new int[]{ 0x1f5a5 }, 0, 1 ) );
|
||||
_addEntry( "desktop_computer", new String( new int[]{ 0x1f5a5 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init6(){
|
||||
_addEntry( "dg", new String( new int[]{ 0x1f1e9, 0x1f1ec }, 0, 2 ) );
|
||||
_addEntry( "diamond_shape_with_a_dot_inside", new String( new int[]{ 0x1f4a0 }, 0, 1 ) );
|
||||
|
@ -635,6 +651,7 @@ public class EmojiMap {
|
|||
_addEntry( "face_palm_tone4", new String( new int[]{ 0x1f926, 0x1f3fe }, 0, 2 ) );
|
||||
_addEntry( "face_palm_tone5", new String( new int[]{ 0x1f926, 0x1f3ff }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init7(){
|
||||
_addEntry( "face_with_cowboy_hat", new String( new int[]{ 0x1f920 }, 0, 1 ) );
|
||||
_addEntry( "face_with_head_bandage", new String( new int[]{ 0x1f915 }, 0, 1 ) );
|
||||
|
@ -738,6 +755,7 @@ public class EmojiMap {
|
|||
_addEntry( "flag_bf", new String( new int[]{ 0x1f1e7, 0x1f1eb }, 0, 2 ) );
|
||||
_addEntry( "flag_bg", new String( new int[]{ 0x1f1e7, 0x1f1ec }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init8(){
|
||||
_addEntry( "flag_bh", new String( new int[]{ 0x1f1e7, 0x1f1ed }, 0, 2 ) );
|
||||
_addEntry( "flag_bi", new String( new int[]{ 0x1f1e7, 0x1f1ee }, 0, 2 ) );
|
||||
|
@ -841,6 +859,7 @@ public class EmojiMap {
|
|||
_addEntry( "flag_kg", new String( new int[]{ 0x1f1f0, 0x1f1ec }, 0, 2 ) );
|
||||
_addEntry( "flag_kh", new String( new int[]{ 0x1f1f0, 0x1f1ed }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init9(){
|
||||
_addEntry( "flag_ki", new String( new int[]{ 0x1f1f0, 0x1f1ee }, 0, 2 ) );
|
||||
_addEntry( "flag_km", new String( new int[]{ 0x1f1f0, 0x1f1f2 }, 0, 2 ) );
|
||||
|
@ -944,6 +963,7 @@ public class EmojiMap {
|
|||
_addEntry( "flag_tf", new String( new int[]{ 0x1f1f9, 0x1f1eb }, 0, 2 ) );
|
||||
_addEntry( "flag_tg", new String( new int[]{ 0x1f1f9, 0x1f1ec }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init10(){
|
||||
_addEntry( "flag_th", new String( new int[]{ 0x1f1f9, 0x1f1ed }, 0, 2 ) );
|
||||
_addEntry( "flag_tj", new String( new int[]{ 0x1f1f9, 0x1f1ef }, 0, 2 ) );
|
||||
|
@ -1047,6 +1067,7 @@ public class EmojiMap {
|
|||
_addEntry( "goat", new String( new int[]{ 0x1f410 }, 0, 1 ) );
|
||||
_addEntry( "golf", new String( new int[]{ 0x26f3 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init11(){
|
||||
_addEntry( "golfer", new String( new int[]{ 0x1f3cc }, 0, 1 ) );
|
||||
_addEntry( "gorilla", new String( new int[]{ 0x1f98d }, 0, 1 ) );
|
||||
|
@ -1150,6 +1171,7 @@ public class EmojiMap {
|
|||
_addEntry( "hole", new String( new int[]{ 0x1f573 }, 0, 1 ) );
|
||||
_addEntry( "homes", new String( new int[]{ 0x1f3d8 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init12(){
|
||||
_addEntry( "honey_pot", new String( new int[]{ 0x1f36f }, 0, 1 ) );
|
||||
_addEntry( "horse", new String( new int[]{ 0x1f434 }, 0, 1 ) );
|
||||
|
@ -1253,6 +1275,7 @@ public class EmojiMap {
|
|||
_addEntry( "kissing", new String( new int[]{ 0x1f617 }, 0, 1 ) );
|
||||
_addEntry( "kissing_cat", new String( new int[]{ 0x1f63d }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init13(){
|
||||
_addEntry( "kissing_closed_eyes", new String( new int[]{ 0x1f61a }, 0, 1 ) );
|
||||
_addEntry( "kissing_heart", new String( new int[]{ 0x1f618 }, 0, 1 ) );
|
||||
|
@ -1356,6 +1379,7 @@ public class EmojiMap {
|
|||
_addEntry( "male_dancer_tone4", new String( new int[]{ 0x1f57a, 0x1f3fe }, 0, 2 ) );
|
||||
_addEntry( "male_dancer_tone5", new String( new int[]{ 0x1f57a, 0x1f3ff }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init14(){
|
||||
_addEntry( "male_sign", new String( new int[]{ 0x2642 }, 0, 1 ) );
|
||||
_addEntry( "man", new String( new int[]{ 0x1f468 }, 0, 1 ) );
|
||||
|
@ -1459,6 +1483,7 @@ public class EmojiMap {
|
|||
_addEntry( "man_detective_medium_dark_skin_tone", new String( new int[]{ 0x1f575, 0x1f3fe, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_detective_medium_light_skin_tone", new String( new int[]{ 0x1f575, 0x1f3fc, 0x2642 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init15(){
|
||||
_addEntry( "man_detective_medium_skin_tone", new String( new int[]{ 0x1f575, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_detective_tone1", new String( new int[]{ 0x1f575, 0x1f3fb, 0x2642 }, 0, 3 ) );
|
||||
|
@ -1562,6 +1587,7 @@ public class EmojiMap {
|
|||
_addEntry( "man_getting_haircut_medium_skin_tone", new String( new int[]{ 0x1f487, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_getting_haircut_tone1", new String( new int[]{ 0x1f487, 0x1f3fb, 0x2642 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init16(){
|
||||
_addEntry( "man_getting_haircut_tone2", new String( new int[]{ 0x1f487, 0x1f3fc, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_getting_haircut_tone3", new String( new int[]{ 0x1f487, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
|
@ -1665,6 +1691,7 @@ public class EmojiMap {
|
|||
_addEntry( "man_mountain_biking_dark_skin_tone", new String( new int[]{ 0x1f6b5, 0x1f3ff, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_mountain_biking_light_skin_tone", new String( new int[]{ 0x1f6b5, 0x1f3fb, 0x2642 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init17(){
|
||||
_addEntry( "man_mountain_biking_medium_dark_skin_tone", new String( new int[]{ 0x1f6b5, 0x1f3fe, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_mountain_biking_medium_light_skin_tone", new String( new int[]{ 0x1f6b5, 0x1f3fc, 0x2642 }, 0, 3 ) );
|
||||
|
@ -1768,6 +1795,7 @@ public class EmojiMap {
|
|||
_addEntry( "man_running_medium_dark_skin_tone", new String( new int[]{ 0x1f3c3, 0x1f3fe, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_running_medium_light_skin_tone", new String( new int[]{ 0x1f3c3, 0x1f3fc, 0x2642 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init18(){
|
||||
_addEntry( "man_running_medium_skin_tone", new String( new int[]{ 0x1f3c3, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_running_tone1", new String( new int[]{ 0x1f3c3, 0x1f3fb, 0x2642 }, 0, 3 ) );
|
||||
|
@ -1871,6 +1899,7 @@ public class EmojiMap {
|
|||
_addEntry( "man_tipping_hand_medium_skin_tone", new String( new int[]{ 0x1f481, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_tipping_hand_tone1", new String( new int[]{ 0x1f481, 0x1f3fb, 0x2642 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init19(){
|
||||
_addEntry( "man_tipping_hand_tone2", new String( new int[]{ 0x1f481, 0x1f3fc, 0x2642 }, 0, 3 ) );
|
||||
_addEntry( "man_tipping_hand_tone3", new String( new int[]{ 0x1f481, 0x1f3fd, 0x2642 }, 0, 3 ) );
|
||||
|
@ -1974,6 +2003,7 @@ public class EmojiMap {
|
|||
_addEntry( "money_with_wings", new String( new int[]{ 0x1f4b8 }, 0, 1 ) );
|
||||
_addEntry( "moneybag", new String( new int[]{ 0x1f4b0 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init20(){
|
||||
_addEntry( "monkey", new String( new int[]{ 0x1f412 }, 0, 1 ) );
|
||||
_addEntry( "monkey_face", new String( new int[]{ 0x1f435 }, 0, 1 ) );
|
||||
|
@ -2077,6 +2107,7 @@ public class EmojiMap {
|
|||
_addEntry( "no_good_tone4", new String( new int[]{ 0x1f645, 0x1f3fe }, 0, 2 ) );
|
||||
_addEntry( "no_good_tone5", new String( new int[]{ 0x1f645, 0x1f3ff }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init21(){
|
||||
_addEntry( "no_mobile_phones", new String( new int[]{ 0x1f4f5 }, 0, 1 ) );
|
||||
_addEntry( "no_mouth", new String( new int[]{ 0x1f636 }, 0, 1 ) );
|
||||
|
@ -2180,6 +2211,7 @@ public class EmojiMap {
|
|||
_addEntry( "peace_symbol", new String( new int[]{ 0x262e }, 0, 1 ) );
|
||||
_addEntry( "peach", new String( new int[]{ 0x1f351 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init22(){
|
||||
_addEntry( "peanuts", new String( new int[]{ 0x1f95c }, 0, 1 ) );
|
||||
_addEntry( "pear", new String( new int[]{ 0x1f350 }, 0, 1 ) );
|
||||
|
@ -2283,6 +2315,7 @@ public class EmojiMap {
|
|||
_addEntry( "point_up_2_tone2", new String( new int[]{ 0x1f446, 0x1f3fc }, 0, 2 ) );
|
||||
_addEntry( "point_up_2_tone3", new String( new int[]{ 0x1f446, 0x1f3fd }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init23(){
|
||||
_addEntry( "point_up_2_tone4", new String( new int[]{ 0x1f446, 0x1f3fe }, 0, 2 ) );
|
||||
_addEntry( "point_up_2_tone5", new String( new int[]{ 0x1f446, 0x1f3ff }, 0, 2 ) );
|
||||
|
@ -2386,6 +2419,7 @@ public class EmojiMap {
|
|||
_addEntry( "raised_hand_with_fingers_splayed_tone3", new String( new int[]{ 0x1f590, 0x1f3fd }, 0, 2 ) );
|
||||
_addEntry( "raised_hand_with_fingers_splayed_tone4", new String( new int[]{ 0x1f590, 0x1f3fe }, 0, 2 ) );
|
||||
}
|
||||
|
||||
private static void init24(){
|
||||
_addEntry( "raised_hand_with_fingers_splayed_tone5", new String( new int[]{ 0x1f590, 0x1f3ff }, 0, 2 ) );
|
||||
_addEntry( "raised_hand_with_part_between_middle_and_ring_fingers", new String( new int[]{ 0x1f596 }, 0, 1 ) );
|
||||
|
@ -2489,6 +2523,7 @@ public class EmojiMap {
|
|||
_addEntry( "rose", new String( new int[]{ 0x1f339 }, 0, 1 ) );
|
||||
_addEntry( "rosette", new String( new int[]{ 0x1f3f5 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init25(){
|
||||
_addEntry( "rotating_light", new String( new int[]{ 0x1f6a8 }, 0, 1 ) );
|
||||
_addEntry( "round_pushpin", new String( new int[]{ 0x1f4cd }, 0, 1 ) );
|
||||
|
@ -2592,6 +2627,7 @@ public class EmojiMap {
|
|||
_addEntry( "six", new String( new int[]{ 0x0036, 0x20e3 }, 0, 2 ) );
|
||||
_addEntry( "six_pointed_star", new String( new int[]{ 0x1f52f }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init26(){
|
||||
_addEntry( "sj", new String( new int[]{ 0x1f1f8, 0x1f1ef }, 0, 2 ) );
|
||||
_addEntry( "sk", new String( new int[]{ 0x1f1f8, 0x1f1f0 }, 0, 2 ) );
|
||||
|
@ -2695,6 +2731,7 @@ public class EmojiMap {
|
|||
_addEntry( "station", new String( new int[]{ 0x1f689 }, 0, 1 ) );
|
||||
_addEntry( "statue_of_liberty", new String( new int[]{ 0x1f5fd }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init27(){
|
||||
_addEntry( "steam_locomotive", new String( new int[]{ 0x1f682 }, 0, 1 ) );
|
||||
_addEntry( "stew", new String( new int[]{ 0x1f372 }, 0, 1 ) );
|
||||
|
@ -2798,6 +2835,7 @@ public class EmojiMap {
|
|||
_addEntry( "tickets", new String( new int[]{ 0x1f39f }, 0, 1 ) );
|
||||
_addEntry( "tiger", new String( new int[]{ 0x1f42f }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init28(){
|
||||
_addEntry( "tiger2", new String( new int[]{ 0x1f405 }, 0, 1 ) );
|
||||
_addEntry( "timer", new String( new int[]{ 0x23f2 }, 0, 1 ) );
|
||||
|
@ -2901,6 +2939,7 @@ public class EmojiMap {
|
|||
_addEntry( "ve", new String( new int[]{ 0x1f1fb, 0x1f1ea }, 0, 2 ) );
|
||||
_addEntry( "vertical_traffic_light", new String( new int[]{ 0x1f6a6 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init29(){
|
||||
_addEntry( "vg", new String( new int[]{ 0x1f1fb, 0x1f1ec }, 0, 2 ) );
|
||||
_addEntry( "vhs", new String( new int[]{ 0x1f4fc }, 0, 1 ) );
|
||||
|
@ -3004,6 +3043,7 @@ public class EmojiMap {
|
|||
_addEntry( "woman_astronaut_dark_skin_tone", new String( new int[]{ 0x1f469, 0x1f3ff, 0x1f680 }, 0, 3 ) );
|
||||
_addEntry( "woman_astronaut_light_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fb, 0x1f680 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init30(){
|
||||
_addEntry( "woman_astronaut_medium_dark_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fe, 0x1f680 }, 0, 3 ) );
|
||||
_addEntry( "woman_astronaut_medium_light_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fc, 0x1f680 }, 0, 3 ) );
|
||||
|
@ -3107,6 +3147,7 @@ public class EmojiMap {
|
|||
_addEntry( "woman_factory_worker_medium_dark_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fe, 0x1f3ed }, 0, 3 ) );
|
||||
_addEntry( "woman_factory_worker_medium_light_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fc, 0x1f3ed }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init31(){
|
||||
_addEntry( "woman_factory_worker_medium_skin_tone", new String( new int[]{ 0x1f469, 0x1f3fd, 0x1f3ed }, 0, 3 ) );
|
||||
_addEntry( "woman_factory_worker_tone1", new String( new int[]{ 0x1f469, 0x1f3fb, 0x1f3ed }, 0, 3 ) );
|
||||
|
@ -3210,6 +3251,7 @@ public class EmojiMap {
|
|||
_addEntry( "woman_guard_medium_skin_tone", new String( new int[]{ 0x1f482, 0x1f3fd, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "woman_guard_tone1", new String( new int[]{ 0x1f482, 0x1f3fb, 0x2640 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init32(){
|
||||
_addEntry( "woman_guard_tone2", new String( new int[]{ 0x1f482, 0x1f3fc, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "woman_guard_tone3", new String( new int[]{ 0x1f482, 0x1f3fd, 0x2640 }, 0, 3 ) );
|
||||
|
@ -3313,6 +3355,7 @@ public class EmojiMap {
|
|||
_addEntry( "woman_playing_handball_tone2", new String( new int[]{ 0x1f93e, 0x1f3fc, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "woman_playing_handball_tone3", new String( new int[]{ 0x1f93e, 0x1f3fd, 0x2640 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init33(){
|
||||
_addEntry( "woman_playing_handball_tone4", new String( new int[]{ 0x1f93e, 0x1f3fe, 0x2640 }, 0, 3 ) );
|
||||
_addEntry( "woman_playing_handball_tone5", new String( new int[]{ 0x1f93e, 0x1f3ff, 0x2640 }, 0, 3 ) );
|
||||
|
@ -3416,6 +3459,7 @@ public class EmojiMap {
|
|||
_addEntry( "woman_singer_tone4", new String( new int[]{ 0x1f469, 0x1f3fe, 0x1f3a4 }, 0, 3 ) );
|
||||
_addEntry( "woman_singer_tone5", new String( new int[]{ 0x1f469, 0x1f3ff, 0x1f3a4 }, 0, 3 ) );
|
||||
}
|
||||
|
||||
private static void init34(){
|
||||
_addEntry( "woman_student", new String( new int[]{ 0x1f469, 0x1f393 }, 0, 2 ) );
|
||||
_addEntry( "woman_student_dark_skin_tone", new String( new int[]{ 0x1f469, 0x1f3ff, 0x1f393 }, 0, 3 ) );
|
||||
|
@ -3519,6 +3563,7 @@ public class EmojiMap {
|
|||
_addEntry( "worried", new String( new int[]{ 0x1f61f }, 0, 1 ) );
|
||||
_addEntry( "worship_symbol", new String( new int[]{ 0x1f6d0 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
private static void init35(){
|
||||
_addEntry( "wrench", new String( new int[]{ 0x1f527 }, 0, 1 ) );
|
||||
_addEntry( "wrestlers", new String( new int[]{ 0x1f93c }, 0, 1 ) );
|
||||
|
@ -3547,6 +3592,7 @@ public class EmojiMap {
|
|||
_addEntry( "zw", new String( new int[]{ 0x1f1ff, 0x1f1fc }, 0, 2 ) );
|
||||
_addEntry( "zzz", new String( new int[]{ 0x1f4a4 }, 0, 1 ) );
|
||||
}
|
||||
|
||||
static{
|
||||
init1();
|
||||
init2();
|
||||
|
@ -3583,9 +3629,8 @@ public class EmojiMap {
|
|||
init33();
|
||||
init34();
|
||||
init35();
|
||||
|
||||
}
|
||||
//codepoint_max=0x1f9c0, length_max=4
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.text.SpannableStringBuilder;
|
|||
import android.text.Spanned;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public abstract class Emojione
|
|||
private static final Pattern SHORTNAME_PATTERN = Pattern.compile(":([-+\\w]+):");
|
||||
|
||||
public static final HashMap<String,String> map_name2unicode = EmojiMap._shortNameToUnicode;
|
||||
public static final HashMap<String,String> map_unicode2name = EmojiMap._unicodeToShortName;
|
||||
public static final HashSet<String> set_unicode = EmojiMap._unicode_set;
|
||||
|
||||
static class DecodeEnv{
|
||||
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
|
@ -45,46 +46,36 @@ public abstract class Emojione
|
|||
int end = s.length();
|
||||
while( i < end ){
|
||||
int remain = end - i;
|
||||
if( remain >= 4 ){
|
||||
String check = s.substring( i, i + 4 );
|
||||
if( map_unicode2name.containsKey( check ) ){
|
||||
addEmoji( check );
|
||||
i += 4;
|
||||
String emoji = null;
|
||||
for(int j = EmojiMap.max_length; j>0;--j ){
|
||||
if( j > remain ) continue;
|
||||
String check = s.substring( i, i + j );
|
||||
if( ! set_unicode.contains( check ) ) continue;
|
||||
emoji = check;
|
||||
break;
|
||||
}
|
||||
if( emoji != null ){
|
||||
addEmoji( emoji );
|
||||
i += emoji.length();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( remain >= 3 ){
|
||||
String check = s.substring( i, i + 3 );
|
||||
if( map_unicode2name.containsKey( check ) ){
|
||||
addEmoji( check );
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( remain >= 2 ){
|
||||
String check = s.substring( i, i + 2 );
|
||||
if( map_unicode2name.containsKey( check ) ){
|
||||
addEmoji( check );
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( remain >= 1 ){
|
||||
String check = s.substring( i, i + 1 );
|
||||
if( map_unicode2name.containsKey( check ) ){
|
||||
addEmoji( check );
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
closeSpan();
|
||||
int length = Character.charCount( s.codePointAt( i ) );
|
||||
if( length == 1){
|
||||
sb.append( s.charAt( i ) );
|
||||
++ i;
|
||||
}else{
|
||||
sb.append( s.substring( i,i+length ));
|
||||
i+= length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence decodeEmoji( String s ){
|
||||
|
||||
|
||||
|
||||
DecodeEnv decode_env = new DecodeEnv();
|
||||
Matcher matcher = SHORTNAME_PATTERN.matcher(s);
|
||||
int last_end = 0;
|
||||
|
@ -103,13 +94,13 @@ public abstract class Emojione
|
|||
decode_env.addEmoji( unicode );
|
||||
}
|
||||
}
|
||||
// close span
|
||||
decode_env.closeSpan();
|
||||
// copy remain
|
||||
int end = s.length();
|
||||
if( end > last_end ){
|
||||
decode_env.addUnicodeString(s.substring( last_end, end ));
|
||||
}
|
||||
// close span
|
||||
decode_env.closeSpan();
|
||||
return decode_env.sb;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jp.juggler.subwaytooter.BuildConfig;
|
||||
import jp.juggler.subwaytooter.api.entity.TootMention;
|
||||
|
||||
public class HTMLDecoder {
|
||||
|
@ -207,6 +208,10 @@ public class HTMLDecoder {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isWhitespace( char c ){
|
||||
return Character.isWhitespace( c ) || c == 0x0a || c == 0x0d;
|
||||
}
|
||||
|
||||
public static SpannableStringBuilder decodeHTML( LinkClickContext account, String src ){
|
||||
try{
|
||||
TokenParser tracker = new TokenParser( src );
|
||||
|
@ -217,7 +222,7 @@ public class HTMLDecoder {
|
|||
|
||||
rootNode.encodeSpan( account, sb );
|
||||
int end = sb.length();
|
||||
while( end > 0 && Character.isWhitespace( sb.charAt( end - 1 ) ) ) -- end;
|
||||
while( end > 0 && isWhitespace( sb.charAt( end - 1 ) ) ) -- end;
|
||||
if( end < sb.length() ){
|
||||
sb.delete( end, sb.length() );
|
||||
}
|
||||
|
|
|
@ -179,6 +179,16 @@ public class Utils {
|
|||
return a == null ? b == null : a.equals( b );
|
||||
}
|
||||
|
||||
public static CharSequence dumpCodePoints(String str){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i=0,ie=str.length(),cp;i<ie;i+=Character.charCount(cp)){
|
||||
cp = str.codePointAt( i );
|
||||
sb.append( String.format( "0x%x,", cp ) );
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
||||
static final char[] hex = new char[]{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
|
||||
public static void addHex( StringBuilder sb, byte b ){
|
||||
|
|
Loading…
Reference in New Issue