本文整理汇总了PHP中io::isUTF8方法的典型用法代码示例。如果您正苦于以下问题:PHP io::isUTF8方法的具体用法?PHP io::isUTF8怎么用?PHP io::isUTF8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io
的用法示例。
在下文中一共展示了io::isUTF8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DOMElementToString
public static function DOMElementToString($domelement, $contentOnly = false)
{
if (!is_a($domelement, "DOMElement")) {
CMS_grandFather::raiseError('Domelement is not a DOMElement instance');
return false;
}
static $autoClosedTagsList;
if (!$autoClosedTagsList) {
$xml2Array = new CMS_xml2Array();
$tagsList = $xml2Array->getAutoClosedTagsList();
$autoClosedTagsList = implode($tagsList, '|');
}
$output = '';
if ($contentOnly) {
$output = '';
foreach ($domelement->childNodes as $node) {
$output .= $node->ownerDocument->saveXML($node, LIBXML_NOEMPTYTAG);
}
} else {
$output = $domNode->ownerDocument->saveXML($domNode, LIBXML_NOEMPTYTAG);
}
//convert output encoding if needed
if (io::isUTF8($output)) {
if (io::strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
$output = utf8_decode($output);
}
} else {
if (io::strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
$output = utf8_encode($output);
}
}
//to correct a bug in libXML < 2.6.27
if (LIBXML_VERSION < 20627 && strpos($output, '&#x') !== false) {
$output = preg_replace_callback('/(&#x[0-9A-Z]+;)/U', create_function('$matches', 'return io::decodeEntities($matches[0]);'), $output);
}
//replace tags like <br></br> by auto closed tags and strip cariage return arround entities
$output = preg_replace(array('#\\n(&[a-z]+;)\\n#U', '#<(' . $autoClosedTagsList . ')([^>]*)></\\1>#U'), array('\\1', '<\\1\\2/>'), $output);
return $output;
}
示例2: md5
CMS_grandFather::raiseError('Action on this type of file is not allowed.');
$view->show();
}
$fileId = md5($file);
$file = new CMS_file($file);
$fileDefinition = $file->readContent();
$labelField = '';
$anchor = '-60';
$action = 'update';
}
if (strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
if (!io::isUTF8($fileDefinition)) {
$fileDefinition = utf8_encode($fileDefinition);
}
} else {
if (io::isUTF8($fileDefinition)) {
$fileDefinition = utf8_decode($fileDefinition);
}
}
//DEFINITION TAB
$content = '<textarea id="file-content-' . $fileId . '" style="display:none;">' . htmlspecialchars($fileDefinition) . '</textarea>';
$view->setContent($content);
switch ($extension) {
case 'less':
case 'css':
$codemirrorConf = '
mode: "text/css",
';
$title = sensitiveIO::sanitizeJSString($fileCreation ? $cms_language->getMessage(MESSAGE_PAGE_CREATE_CSS) : $cms_language->getMessage(MESSAGE_PAGE_EDIT_CSS) . ' ' . $node);
break;
case 'js':
示例3: executeSqlScript
/**
* Execute a SQL script
*
* @param $script, string : the CMS_file::FILE_SYSTEM SQL script filename
* This script can be SQL export provided by phpMyadmin or mysqldump, etc.
* @param simulation : boolean, if true, only do a read of the script and if it contain sql data, return true.
* @return boolean, true on success, false on failure
* @access public
*/
function executeSqlScript($script, $simulation = false)
{
//include PMA import functions
require_once PATH_PACKAGES_FS . '/files/sqlDump.php';
//read mysql version and set needed constant/vars for phpMyAdmin
$q = new CMS_query('SELECT VERSION() AS version');
$version = $q->getValue('version');
$match = explode('.', $version);
//read mysql file
$query = PMA_readFile($script);
//first, detect SQL file encoding
$isUTF8 = io::isUTF8($query);
//then, change charset declaration inside sql queries to match current Automne charset
if (strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
//if Automne is not in utf8, then table charset must be in latin1
$query = str_ireplace(' CHARSET=utf8', ' CHARSET=latin1', $query);
$query = str_ireplace('TYPE=MyISAM;', 'TYPE=MyISAM CHARSET=latin1;', $query);
} else {
//if Automne is in utf8, then table charset must be in utf8
$query = str_ireplace(' CHARSET=latin1', ' CHARSET=utf8', $query);
$query = str_ireplace('TYPE=MyISAM;', 'TYPE=MyISAM CHARSET=utf8;', $query);
}
//finally, clean it and split queries
PMA_splitSqlFile($queries, $query, (int) sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
if (!$simulation) {
//set connection charset accordingly to file charset
if ($isUTF8) {
$q = new CMS_query("SET NAMES 'utf8'");
} else {
$q = new CMS_query("SET NAMES 'latin1'");
}
//execute all queries
$ok = true;
foreach ($queries as $aQuery) {
$q = new CMS_query($aQuery);
$ok = $q->hasError() ? false : $ok;
}
//set connection charset accordingly to file charset
if ($isUTF8) {
$q = new CMS_query("SET NAMES 'latin1'");
} else {
$q = new CMS_query("SET NAMES 'utf8'");
}
} else {
$ok = is_array($queries) && $queries ? true : false;
}
//reset connection charset
if (io::strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
//set connection to utf-8 charset
$q = new CMS_query("SET NAMES 'utf8'");
} else {
$q = new CMS_query("SET NAMES 'latin1'");
}
return $ok;
}