$test_docomo = "Hello " . utf8_bytes(0xe6e7); $test_kddi = "Hello " . utf8_bytes(0xe527); $test_google = "Hello " . utf8_bytes(0xfe833); $test_html = "Hello <span class=\"emoji emoji3620e3\"></span>"; is(tt_emoji_docomo_to_unified($test_docomo), $test_unified, "DoCoMo -> Unified"); is(tt_emoji_kddi_to_unified($test_kddi), $test_unified, "KDDI -> Unified"); is(tt_emoji_softbank_to_unified($test_iphone), $test_unified, "Softbank -> Unified"); is(tt_emoji_google_to_unified($test_google), $test_unified, "Google -> Unified"); echo "#------------------\n"; is(tt_emoji_unified_to_docomo($test_unified), $test_docomo, "Unified -> DoCoMo"); is(tt_emoji_unified_to_kddi($test_unified), $test_kddi, "Unified -> KDDI"); is(tt_emoji_unified_to_softbank($test_unified), $test_iphone, "Unified -> Softbank"); is(tt_emoji_unified_to_google($test_unified), $test_google, "Unified -> Google"); echo "#------------------\n"; is(tt_emoji_unified_to_html($test_unified), $test_html, "Unified -> HTML"); is(tt_emoji_html_to_unified($test_html), $test_unified, "HTML -> Unified"); echo "#------------------\n"; # # names are accessed by the unified codepoint (which makes it tricky for 2-codepoint unicode symbols) # is(tt_emoji_get_name(utf8_bytes(0x2600)), 'BLACK SUN WITH RAYS', "name U+2600"); is(tt_emoji_get_name(utf8_bytes(0x26ea)), 'CHURCH', "name U+26EA"); is(tt_emoji_get_name(utf8_bytes(0x1f480)), 'SKULL', "name U+1F480"); is(tt_emoji_get_name(utf8_bytes(0x1f450)), 'OPEN HANDS SIGN', "name U+1F450"); is(tt_emoji_get_name(utf8_bytes(0x1f52b)), 'PISTOL', "name U+1F52B"); is(tt_emoji_get_name(utf8_bytes(0x36) . utf8_bytes(0x20e3)), 'KEYCAP 6', "name U+36 U+20E3"); # # below here are the test helper functions # function is($got, $expected, $name) {
# 2 bytes return chr(0xc0 | ($cp & 0x7c0) >> 6) . chr(0x80 | $cp & 0x3f); } else { # 1 byte return chr($cp); } } } } foreach ($src as $unified) { $bytes = ''; $hex = array(); foreach ($unified as $cp) { $bytes .= utf8_bytes($cp); $hex[] = sprintf('U+%04X', $cp); } $str = "Hello {$bytes} World"; echo "<tr>\n"; echo "<td>" . implode(' ', $hex) . "</td>\n"; echo "<td>" . HtmlSpecialChars(tt_emoji_get_name($bytes)) . "</td>\n"; echo "<td>{$str}</td>\n"; echo "<td>" . tt_emoji_unified_to_html($str) . "</td>\n"; echo "<td>" . tt_emoji_html_to_unified(tt_emoji_unified_to_html($str)) . "</td>\n"; echo "</tr>\n"; } ?> </table> </body> </html>