is(emoji_unified_to_kddi($test_unified), $test_kddi, "Unified -> KDDI"); is(emoji_unified_to_softbank($test_unified), $test_iphone, "Unified -> Softbank"); is(emoji_unified_to_google($test_unified), $test_google, "Unified -> Google"); echo "#------------------\n"; is(emoji_unified_to_html($test_unified), $test_html, "Unified -> HTML"); is(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(emoji_get_name(utf8_bytes(0x2600)), 'BLACK SUN WITH RAYS', "name U+2600"); is(emoji_get_name(utf8_bytes(0x26ea)), 'CHURCH', "name U+26EA"); is(emoji_get_name(utf8_bytes(0x1f480)), 'SKULL', "name U+1F480"); is(emoji_get_name(utf8_bytes(0x1f450)), 'OPEN HANDS SIGN', "name U+1F450"); is(emoji_get_name(utf8_bytes(0x1f52b)), 'PISTOL', "name U+1F52B"); is(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)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>EMoji HTML Test</title> <link href="emoji.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="1"> <tr> <th>Unified</th> <th>Name</th> <th>Unified Text</th> <th>HTML</th> </tr> <?php foreach (array(0x2600, 0x1f493, 0x1f502) as $unified) { $bytes = "Hello " . emoji_utf8_bytes($unified) . " World"; echo "<tr>\n"; echo "<td>" . sprintf('U+%04X', $unified) . "</td>\n"; echo "<td>" . HtmlSpecialChars(emoji_get_name($unified)) . "</td>\n"; echo "<td>{$bytes}</td>\n"; echo "<td>" . emoji_unified_to_html($bytes) . "</td>\n"; echo "</tr>\n"; } ?> </table> </body> </html>