本文整理汇总了PHP中eZLocale::charset方法的典型用法代码示例。如果您正苦于以下问题:PHP eZLocale::charset方法的具体用法?PHP eZLocale::charset怎么用?PHP eZLocale::charset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZLocale
的用法示例。
在下文中一共展示了eZLocale::charset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findAppropriateCharsetsList
/**
* @param \eZLocale $primaryLanguage
* @param \eZLocale[]|null $allLanguages
* @param bool $canUseUnicode
* @return array
*/
function findAppropriateCharsetsList($primaryLanguage, $allLanguages, $canUseUnicode)
{
$commonCharsets = array();
if (is_array($allLanguages) and count($allLanguages) > 0) {
$language = $allLanguages[0];
$charsets = $language->allowedCharsets();
foreach ($charsets as $charset) {
$commonCharsets[] = eZCharsetInfo::realCharsetCode($charset);
}
$commonCharsets = array_unique($commonCharsets);
for ($i = 1; $i < count($allLanguages); ++$i) {
$language = $allLanguages[$i];
$charsets = $language->allowedCharsets();
$realCharsets = array();
foreach ($charsets as $charset) {
$realCharsets[] = eZCharsetInfo::realCharsetCode($charset);
}
$realCharsets = array_unique($realCharsets);
$commonCharsets = array_intersect($commonCharsets, $realCharsets);
}
}
$usableCharsets = array_values($commonCharsets);
if (count($usableCharsets) > 0) {
if (in_array($primaryLanguage->charset(), $usableCharsets)) {
array_unshift($usableCharsets, $primaryLanguage->charset());
$usableCharsets = array_unique($usableCharsets);
}
} else {
if ($canUseUnicode) {
$usableCharsets[] = eZCharsetInfo::realCharsetCode('utf-8');
}
}
return $usableCharsets;
}