本文整理汇总了PHP中SystemTextEncoding::isUtf8方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemTextEncoding::isUtf8方法的具体用法?PHP SystemTextEncoding::isUtf8怎么用?PHP SystemTextEncoding::isUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemTextEncoding
的用法示例。
在下文中一共展示了SystemTextEncoding::isUtf8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toStorageEncoding
/**
* Decode a string from UTF8 to current Storage Charset
* @static
* @param string $filesystemElement
* @param bool $test Try to detect if it's really utf8 or not
* @return string
*/
public static function toStorageEncoding($filesystemElement, $test = false)
{
if ($test && !SystemTextEncoding::isUtf8($filesystemElement)) {
return $filesystemElement;
}
$enc = SystemTextEncoding::getEncoding();
return SystemTextEncoding::changeCharset("UTF-8", $enc, $filesystemElement);
}
示例2: mimeExtractorCallback
public function mimeExtractorCallback($masterFile, $targetFile)
{
$metadata = array();
require_once "Mail/mimeDecode.php";
$params = array('include_bodies' => true, 'decode_bodies' => false, 'decode_headers' => 'UTF-8');
$mess = ConfService::getMessages();
$content = file_get_contents($masterFile);
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$allowedHeaders = array("to", "from", "subject", "message-id", "mime-version", "date", "return-path");
foreach ($structure->headers as $hKey => $hValue) {
if (!in_array($hKey, $allowedHeaders)) {
continue;
}
if (is_array($hValue)) {
$hValue = implode(", ", $hValue);
}
if ($hKey == "date") {
$date = strtotime($hValue);
$metadata["eml_time"] = $date;
}
$metadata["eml_" . $hKey] = AJXP_Utils::xmlEntities(@htmlentities($hValue, ENT_COMPAT, "UTF-8"));
//$this->logDebug($hKey." - ".$hValue. " - ".$metadata["eml_".$hKey]);
if ($metadata["eml_" . $hKey] == "") {
$metadata["eml_" . $hKey] = AJXP_Utils::xmlEntities(@htmlentities($hValue));
if (!SystemTextEncoding::isUtf8($metadata["eml_" . $hKey])) {
$metadata["eml_" . $hKey] = SystemTextEncoding::toUTF8($metadata["eml_" . $hKey]);
}
}
$metadata["eml_" . $hKey] = str_replace("&", "&", $metadata["eml_" . $hKey]);
}
$metadata["eml_attachments"] = 0;
$parts = $structure->parts;
if (!empty($parts)) {
foreach ($parts as $mimePart) {
if (!empty($mimePart->disposition) && $mimePart->disposition == "attachment") {
$metadata["eml_attachments"]++;
}
}
}
$metadata["icon"] = "eml_images/ICON_SIZE/mail_mime.png";
file_put_contents($targetFile, serialize($metadata));
}
示例3: toUTF8
/**
* Transform a string from current charset to utf8
* @static
* @param string $filesystemElement
* @param bool $test Test if it's already UTF8 or not, to avoid double-encoding
* @return string
*/
static function toUTF8($filesystemElement, $test = true)
{
if ($test && SystemTextEncoding::isUtf8($filesystemElement)) {
return $filesystemElement;
}
$enc = SystemTextEncoding::getEncoding();
return SystemTextEncoding::changeCharset($enc, "UTF-8", $filesystemElement);
}