本文整理汇总了PHP中utf8::utf8_to_numeric方法的典型用法代码示例。如果您正苦于以下问题:PHP utf8::utf8_to_numeric方法的具体用法?PHP utf8::utf8_to_numeric怎么用?PHP utf8::utf8_to_numeric使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utf8
的用法示例。
在下文中一共展示了utf8::utf8_to_numeric方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUtf8_to_numeric
public function testUtf8_to_numeric()
{
$s = 'é';
$as = 0xe9;
$rs = utf8::utf8_to_numeric($s);
$this->assertEquals($as, $rs, '1 - ');
$s = '5';
$as = 0x35;
$rs = utf8::utf8_to_numeric($s);
$this->assertEquals($as, $rs, '2 - ');
}
示例2: iciUnicodeToNoAipaitai
public static function iciUnicodeToNoAipaitai($text)
{
$cnt = mb_strlen($text, 'UTF-8');
$text_noaipaitai = "";
for ($i = 0; $i < $cnt; $i++) {
$c = mb_substr($text, $i, 1, 'UTF-8');
$nc = utf8::utf8_to_numeric($c);
if (array_key_exists($nc, self::$ais_in_unicode)) {
$a = self::$ais_in_unicode[$nc]['UCnoaipaitai'];
$utf8 = utf8::numeric_to_utf8($a);
$text_noaipaitai .= $utf8;
} else {
$text_noaipaitai .= $c;
}
}
return $text_noaipaitai;
}
示例3: legacyToUnicode
public static function legacyToUnicode($text, $aipaitai)
{
$cs = array();
$dot = FALSE;
$i = 0;
$l = mb_strlen($text);
$text_transcode = '';
while ($i < $l) {
$c = mb_substr($text, $i, 1);
$nc = utf8::utf8_to_numeric($c);
if ($nc == ord('w')) {
$d = 0x1403;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('W')) {
$d = 0x1431;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('t')) {
$d = 0x144e;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('r')) {
# ki
$d = 0x146d;
if ($dot) {
array_pop($cs);
}
if (count($cs) > 1 && $cs[count($cs) - 1] == 0x1550 && $cs[count($cs) - 2] == 0x1550) {
array_pop($cs);
array_pop($cs);
array_push($cs, 0x1585);
} elseif (count($cs) > 1 && $cs[count($cs) - 1] == 0x1550 && $cs[count($cs) - 2] == 0x1585) {
array_pop($cs);
} elseif (count($cs) > 0 && $cs[count($cs) - 1] == 0x1550) {
array_pop($cs);
$d = 0x157f;
}
if ($dot) {
$dot = FALSE;
$d++;
}
} elseif ($nc == ord('Q')) {
# gi
$d = 0x148b;
if ($dot) {
array_pop($cs);
}
if (count($cs) != 0) {
$e = $cs[count($cs) - 1];
if ($e == 0x1595) {
# ng+gi
array_pop($cs);
$d = 0x158f;
# ngi
} elseif ($e == 0x1596) {
#nng+gi
array_pop($cs);
$d = 0x1671;
# nngi
}
}
if ($dot) {
$dot = FALSE;
$d++;
}
} elseif ($nc == ord('u')) {
$d = 0x14a5;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('i')) {
$d = 0x14c2;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('y')) {
$d = 0x14ef;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('o')) {
$d = 0x14d5;
if ($dot) {
$dot = FALSE;
//.........这里部分代码省略.........
示例4: legacyToUnicode
public static function legacyToUnicode($text, $aipaitai)
{
$cs = array();
$dot = FALSE;
$i = 0;
$l = mb_strlen($text);
while ($i < $l) {
$c = mb_substr($text, $i, 1);
$nc = utf8::utf8_to_numeric($c);
if ($nc == ord('w')) {
$d = 0x1403;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('W')) {
$d = 0x1431;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('t')) {
$d = 0x144e;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('r')) {
# ki
$d = 0x146d;
if ($dot) {
array_pop($cs);
}
if (count($cs) > 1 && $cs[count($cs) - 1] == 0x1550 && $cs[count($cs) - 2] == 0x1550) {
array_pop($cs);
array_pop($cs);
array_push($cs, 0x1585);
} elseif (count($cs) > 1 && $cs[count($cs) - 1] == 0x1550 && $cs[count($cs) - 2] == 0x1585) {
array_pop($cs);
} elseif (count($cs) > 0 && $cs[count($cs) - 1] == 0x1550) {
array_pop($cs);
$d = 0x157f;
}
if ($dot) {
$dot = FALSE;
$d++;
}
} elseif ($nc == ord('Q')) {
# gi
$d = 0x148b;
if ($dot) {
array_pop($cs);
}
if (count($cs) != 0) {
$e = $cs[count($cs) - 1];
if ($e == 0x1595) {
# ng+gi
array_pop($cs);
$d = 0x158f;
# ngi
} elseif ($e == 0x1596) {
#nng+gi
array_pop($cs);
$d = 0x1671;
# nngi
}
}
if ($dot) {
$dot = FALSE;
$d++;
}
} elseif ($nc == ord('u')) {
$d = 0x14a5;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('i')) {
$d = 0x14c2;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('y')) {
$d = 0x14ef;
if ($dot) {
$dot = FALSE;
array_pop($cs);
$d++;
}
} elseif ($nc == ord('o')) {
$d = 0x14d5;
if ($dot) {
$dot = FALSE;
array_pop($cs);
//.........这里部分代码省略.........
示例5: unicodeToSlashUUnicodeString
function unicodeToSlashUUnicodeString($text)
{
$cnt = mb_strlen($text);
$i = 0;
$res = '';
while ($i < $cnt) {
$c = mb_substr($text, $i++, 1);
$nc = utf8::utf8_to_numeric($c);
$res .= sprintf("\\u%04x", $nc);
}
return $res;
}