本文整理汇总了PHP中UtfNormal::quickIsNFC方法的典型用法代码示例。如果您正苦于以下问题:PHP UtfNormal::quickIsNFC方法的具体用法?PHP UtfNormal::quickIsNFC怎么用?PHP UtfNormal::quickIsNFC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UtfNormal
的用法示例。
在下文中一共展示了UtfNormal::quickIsNFC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Used by runOnCluster to Normalize video titles and metadata
*
* @param DatabaseMysql $db
* @param bool $test
* @param bool $verbose
* @param array $params
*/
public static function run(DatabaseMysql $db, $test, $verbose = false, $params)
{
if (!$db->tableExists('image') || !$db->tableExists('video_info')) {
echo "ERROR: {$params['dbname']} (ID:{$params['cityId']}): image/video_info table does not exist.\n";
return;
}
foreach (self::getVideoRows($db) as $video) {
$originalName = $video->img_name;
if (\UtfNormal::quickIsNFC($originalName)) {
if ($verbose) {
echo "Already in NFC form; skipping: {$originalName}\n";
}
continue;
}
self::updateVideo($video, $db, $test, $verbose);
}
}
示例2: toNFC
/**
* Convert a UTF-8 string to normal form C, canonical composition.
* Fast return for pure ASCII strings; some lesser optimizations for
* strings containing only known-good characters.
*
* @param $string String: a valid UTF-8 string. Input is not validated.
* @return string a UTF-8 string in normal form C
*/
static function toNFC($string)
{
if (NORMALIZE_INTL) {
return normalizer_normalize($string, Normalizer::FORM_C);
} elseif (NORMALIZE_ICU) {
return utf8_normalize($string, UNORM_NFC);
} elseif (UtfNormal::quickIsNFC($string)) {
return $string;
} else {
return UtfNormal::NFC($string);
}
}