本文整理匯總了PHP中MailSo\Base\Utils::IsUtf8方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::IsUtf8方法的具體用法?PHP Utils::IsUtf8怎麽用?PHP Utils::IsUtf8使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::IsUtf8方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ConvertSystemString
/**
* @return string
*/
public static function ConvertSystemString($sSrt)
{
if (!empty($sSrt) && !\MailSo\Base\Utils::IsUtf8($sSrt)) {
$sCharset = \MailSo\Base\Utils::DetectSystemCharset();
if (!empty($sCharset)) {
$sSrt = \MailSo\Base\Utils::ConvertEncoding($sSrt, $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
} else {
$sSrt = @\utf8_encode($sSrt);
}
}
return $sSrt;
}
示例2: NormalizeCharsetByValue
/**
* @param string $sCharset
* @param string $sValue
*
* @return string
*/
public static function NormalizeCharsetByValue($sCharset, $sValue)
{
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
if (\MailSo\Base\Enumerations\Charset::UTF_8 !== $sCharset && \MailSo\Base\Utils::IsUtf8($sValue) && false === \strpos($sCharset, \MailSo\Base\Enumerations\Charset::ISO_2022_JP)) {
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
return $sCharset;
}
示例3: DecodeHeaderValue
/**
* @param string $sEncodedValue
* @param string $sIncomingCharset = ''
* @param string $sForcedIncomingCharset = ''
*
* @return string
*/
public static function DecodeHeaderValue($sEncodedValue, $sIncomingCharset = '', $sForcedIncomingCharset = '')
{
$sValue = $sEncodedValue;
if (0 < \strlen($sIncomingCharset)) {
if (\MailSo\Base\Enumerations\Charset::UTF_8 !== $sIncomingCharset && \MailSo\Base\Utils::IsUtf8($sValue)) {
$sIncomingCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sIncomingCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
}
$sValue = \preg_replace('/\\?=[\\n\\r\\t\\s]{1,5}=\\?/m', '?==?', $sValue);
$sValue = \preg_replace('/[\\r\\n\\t]+/m', ' ', $sValue);
$aEncodeArray = array('');
$aMatch = array();
\preg_match_all('/=\\?[^\\?]+\\?[q|b|Q|B]\\?[^\\?]*(\\?=)/', $sValue, $aMatch);
if (isset($aMatch[0]) && \is_array($aMatch[0])) {
for ($iIndex = 0, $iLen = \count($aMatch[0]); $iIndex < $iLen; $iIndex++) {
if (isset($aMatch[0][$iIndex])) {
$iPos = @\strpos($aMatch[0][$iIndex], '*');
if (false !== $iPos) {
$aMatch[0][$iIndex][0] = \substr($aMatch[0][$iIndex][0], 0, $iPos);
}
}
}
$aEncodeArray = $aMatch[0];
}
$aParts = array();
$sMainCharset = '';
$bOneCharset = true;
for ($iIndex = 0, $iLen = \count($aEncodeArray); $iIndex < $iLen; $iIndex++) {
$aTempArr = array('', $aEncodeArray[$iIndex]);
if ('=?' === \substr(\trim($aTempArr[1]), 0, 2)) {
$iPos = \strpos($aTempArr[1], '?', 2);
$aTempArr[0] = \substr($aTempArr[1], 2, $iPos - 2);
$sEncType = \strtoupper($aTempArr[1][$iPos + 1]);
switch ($sEncType) {
case 'Q':
$sHeaderValuePart = \str_replace('_', ' ', $aTempArr[1]);
$aTempArr[1] = \quoted_printable_decode(\substr($sHeaderValuePart, $iPos + 3, \strlen($sHeaderValuePart) - $iPos - 5));
break;
case 'B':
$sHeaderValuePart = $aTempArr[1];
$aTempArr[1] = \MailSo\Base\Utils::Base64Decode(\substr($sHeaderValuePart, $iPos + 3, \strlen($sHeaderValuePart) - $iPos - 5));
break;
}
}
if (0 < \strlen($aTempArr[0])) {
$sCharset = 0 === \strlen($sForcedIncomingCharset) ? $aTempArr[0] : $sForcedIncomingCharset;
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset, true);
if ('' === $sMainCharset) {
$sMainCharset = $sCharset;
} else {
if ($sMainCharset !== $sCharset) {
$bOneCharset = false;
}
}
}
$aParts[] = array($aEncodeArray[$iIndex], $aTempArr[1], $sCharset);
unset($aTempArr);
}
for ($iIndex = 0, $iLen = \count($aParts); $iIndex < $iLen; $iIndex++) {
if ($bOneCharset) {
$sValue = \str_replace($aParts[$iIndex][0], $aParts[$iIndex][1], $sValue);
} else {
if (\MailSo\Base\Enumerations\Charset::UTF_8 !== $aParts[$iIndex][2] && \MailSo\Base\Utils::IsUtf8($aParts[$iIndex][1])) {
$aParts[$iIndex][2] = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \str_replace($aParts[$iIndex][0], \MailSo\Base\Utils::ConvertEncoding($aParts[$iIndex][1], $aParts[$iIndex][2], \MailSo\Base\Enumerations\Charset::UTF_8), $sValue);
}
}
if ($bOneCharset && 0 < \strlen($sMainCharset)) {
if (\MailSo\Base\Enumerations\Charset::UTF_8 !== $sMainCharset && \MailSo\Base\Utils::IsUtf8($sValue)) {
$sMainCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sMainCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
}
return $sValue;
}
示例4: Test
/**
* @return string
*/
public function Test()
{
$sResult = '';
try {
$this->SyncDatabase();
if (0 >= $this->getVersion($this->sDsnType . '-ab-version')) {
$sResult = 'Unknown database error';
}
} catch (\Exception $oException) {
$sResult = $oException->getMessage();
if (!empty($sResult) && !\MailSo\Base\Utils::IsAscii($sResult) && !\MailSo\Base\Utils::IsUtf8($sResult)) {
$sResult = @\utf8_encode($sResult);
}
if (!\is_string($sResult) || empty($sResult)) {
$sResult = 'Unknown database error';
}
}
return $sResult;
}