本文整理匯總了PHP中MailSo\Base\Utils::IconvConvertEncoding方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::IconvConvertEncoding方法的具體用法?PHP Utils::IconvConvertEncoding怎麽用?PHP Utils::IconvConvertEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::IconvConvertEncoding方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Utf8Clear
/**
* @param string $sUtfString
* @param string $sReplaceOn = ''
*
* @return string
*/
public static function Utf8Clear($sUtfString, $sReplaceOn = '')
{
if ('' === $sUtfString) {
return $sUtfString;
}
$sUtfString = \preg_replace(\MailSo\Base\Utils::$sValidUtf8Regexp, '$1', $sUtfString);
$sUtfString = \preg_replace('/\\xE0[\\x80-\\x9F][\\x80-\\xBF]' . '|\\xEF\\xBF\\xBF' . '|\\xED[\\xA0-\\xBF][\\x80-\\xBF]/S', $sReplaceOn, $sUtfString);
$sUtfString = \preg_replace('/\\xEF\\xBF\\xBD/', '?', $sUtfString);
$sNewUtfString = false;
if (false === $sNewUtfString && \MailSo\Base\Utils::IsMbStringSupported()) {
$sNewUtfString = \MailSo\Base\Utils::MbConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
}
if (false === $sNewUtfString && \MailSo\Base\Utils::IsIconvSupported()) {
$sNewUtfString = \MailSo\Base\Utils::IconvConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
}
if (false !== $sNewUtfString) {
$sUtfString = $sNewUtfString;
}
return $sUtfString;
}
示例2: Utf8Clear
/**
* @param string $sUtfString
* @param string $sReplaceOn = ''
*
* @return string
*/
public static function Utf8Clear($sUtfString, $sReplaceOn = '')
{
if ('' === $sUtfString) {
return $sUtfString;
}
$sUtfString = \preg_replace('/[\\x00-\\x08\\x10\\x0B\\x0C\\x0E-\\x1F\\x7F]' . '|[\\x00-\\x7F][\\x80-\\xBF]+' . '|([\\xC0\\xC1]|[\\xF0-\\xFF])[\\x80-\\xBF]*' . '|[\\xC2-\\xDF]((?![\\x80-\\xBF])|[\\x80-\\xBF]{2,})' . '|[\\xE0-\\xEF](([\\x80-\\xBF](?![\\x80-\\xBF]))|(?![\\x80-\\xBF]{2})|[\\x80-\\xBF]{3,})/S', $sReplaceOn, $sUtfString);
$sUtfString = \preg_replace('/\\xE0[\\x80-\\x9F][\\x80-\\xBF]' . '|\\xEF\\xBF\\xBF' . '|\\xED[\\xA0-\\xBF][\\x80-\\xBF]/S', $sReplaceOn, $sUtfString);
$sUtfString = \preg_replace('/\\xEF\\xBF\\xBD/', '?', $sUtfString);
$sNewUtfString = false;
if (\MailSo\Base\Utils::IsIconvSupported()) {
$sNewUtfString = \MailSo\Base\Utils::IconvConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
} else {
if (\MailSo\Base\Utils::IsMbStringSupported()) {
$sNewUtfString = \MailSo\Base\Utils::MbConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
}
}
if (false !== $sNewUtfString) {
$sUtfString = $sNewUtfString;
}
return $sUtfString;
}