Ejemplo n.º 1
0
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)
        } else {
            if ($cp > 0x80) {
                # 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>
Ejemplo n.º 3
0
 protected function respText($content)
 {
     if (empty($content)) {
         return error(-1, 'Invaild value');
     }
     if (stripos($content, './') !== false) {
         preg_match_all('/<a .*?href="(.*?)".*?>/is', $content, $urls);
         if (!empty($urls[1])) {
             foreach ($urls[1] as $url) {
                 $content = str_replace($url, $this->buildSiteUrl($url), $content);
             }
         }
     }
     $content = str_replace("\r\n", "\n", $content);
     $response = array();
     $response['FromUserName'] = $this->message['to'];
     $response['ToUserName'] = $this->message['from'];
     $response['MsgType'] = 'text';
     $response['Content'] = htmlspecialchars_decode($content);
     preg_match_all('/\\[U\\+(\\w{4,})\\]/i', $response['Content'], $matchArray);
     if (!empty($matchArray[1])) {
         foreach ($matchArray[1] as $emojiUSB) {
             $response['Content'] = str_ireplace("[U+{$emojiUSB}]", utf8_bytes(hexdec($emojiUSB)), $response['Content']);
         }
     }
     return $response;
 }
Ejemplo n.º 4
0
                    $userInfo = $db->getInfo($weObj->getRevFrom());
                    $db->disconnect();
                    switch ($userInfo['state']) {
                        case 0:
                            $weObj->text("您目前处于未认证状态,请先认证!\n\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>")->reply();
                            break;
                        case 1:
                            $weObj->text("<a href='{$authURI2}'>确认借车                                           </a>")->reply();
                            break;
                        case 2:
                            $weObj->text("您目前处于已借车状态,不能再次借车!\n\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>")->reply();
                            break;
                        case 3:
                            $weObj->text("您目前处于被禁用状态!\n\n<a href='" . $authURI . "'>点此查看原因</a>")->reply();
                            break;
                    }
                } else {
                    if (substr($scan, 0, 5) == "prizea") {
                        // Prize
                        $redirectURI3 = urlencode("http://" . WX_URL . "/main.php?a=prize");
                        $authURI3 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . WX_APPID . "&redirect_uri=" . $redirectURI3 . "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
                        $weObj->text("<a href='{$authURI3}'>点此抽奖~</a>")->reply();
                    }
                }
                break;
        }
        break;
}
$weObj->checkAuth();
$weObj->createMenu(array('button' => array(0 => array('name' => '慈善商店', 'type' => 'view', 'url' => 'http://www.imall365.org/'), 1 => array('name' => WX_TITLE . emoji_docomo_to_unified(utf8_bytes(0x1f6b2)), 'type' => 'view', 'url' => $authURI))));