function emoji_escape($str, $remove = false) { $result = ''; for ($i = 0; $i < strlen($str); $i++) { $emoji = ''; $c1 = ord($str[$i]); if ($GLOBALS['__Framework']['carrier'] == 's') { if ($c1 == 0xf7 || $c1 == 0xf9 || $c1 == 0xfb) { $bin = substr($str, $i, 2); $emoji = emoji_escape_s($bin); } } elseif ($c1 == 0xf8 || $c1 == 0xf9) { $bin = substr($str, $i, 2); $emoji = emoji_escape_i($bin); } elseif (0xf3 <= $c1 && $c1 <= 0xf7) { $bin = substr($str, $i, 2); $emoji = emoji_escape_e($bin); } if ($emoji) { if (!$remove) { $result .= $emoji; } $i++; } else { $result .= $str[$i]; if (0x81 <= $c1 && $c1 <= 0x9f || 0xe0 <= $c1) { $result .= $str[$i + 1]; $i++; } } } return $result; }
function convert_text_core($str) { $result = ""; for ($i = 0; $i < strlen($str); $i++) { $c = 0; $c1 = ord($str[$i]); $c2 = ord($str[$i]); // E-mail用絵文字から携帯用絵文字に変換 if ($c1 == 0xed || $c1 == 0xee) { // [e:358] ~ [e:499]、[e:700]~ $c = hexdec(bin2hex(substr($str, $i, 2))) + 1536; } elseif ($c1 == 0xeb || $c1 == 0xec) { // [e:1]~[e:357]、[e:500]~[e:518] $c = hexdec(bin2hex(substr($str, $i, 2))) + 2816; } if ($c) { $bin = array(); $bin[0] = chr($c >> 8); $bin[1] = chr($c - ($bin[0] << 8)); $emoji = emoji_escape_e($bin); $result .= $emoji; $i++; } else { $result .= $str[$i]; if (0x81 <= $c1 && $c1 <= 0x9f || 0xe0 <= $c1) { $result .= $str[$i + 1]; $i++; } } } return $result; }