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) { $passed = $got === $expected ? 1 : 0; if ($passed) { echo "ok # {$name}\n"; } else { echo "not ok # {$name}\n"; echo "# expected : " . byteify($expected) . "\n"; echo "# got : " . byteify($got) . "\n"; } } function byteify($s)
# 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>