本文整理汇总了PHP中StringUtils::isUtf8方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtils::isUtf8方法的具体用法?PHP StringUtils::isUtf8怎么用?PHP StringUtils::isUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtils
的用法示例。
在下文中一共展示了StringUtils::isUtf8方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkTitleEncoding
/**
* @param string $s
* @return string
*/
function checkTitleEncoding($s)
{
if (is_array($s)) {
throw new MWException('Given array to checkTitleEncoding.');
}
if (StringUtils::isUtf8($s)) {
return $s;
}
return $this->iconv($this->fallback8bitEncoding(), 'utf-8', $s);
}
示例2: checkTitleEncoding
/**
* @param $s string
* @return string
*/
function checkTitleEncoding($s)
{
if (is_array($s)) {
wfDebugDieBacktrace('Given array to checkTitleEncoding.');
}
if (StringUtils::isUtf8($s)) {
return $s;
}
return $this->iconv($this->fallback8bitEncoding(), 'utf-8', $s);
}
示例3: doQuery
protected function doQuery($sql)
{
wfDebug("SQL: [{$sql}]\n");
if (!StringUtils::isUtf8($sql)) {
throw new MWException("SQL encoding is invalid\n{$sql}");
}
// handle some oracle specifics
// remove AS column/table/subquery namings
if (!$this->getFlag(DBO_DDLMODE)) {
$sql = preg_replace('/ as /i', ' ', $sql);
}
// Oracle has issues with UNION clause if the statement includes LOB fields
// So we do a UNION ALL and then filter the results array with array_unique
$union_unique = preg_match('/\\/\\* UNION_UNIQUE \\*\\/ /', $sql) != 0;
// EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
// you have to select data from plan table after explain
$explain_id = MWTimestamp::getLocalInstance()->format('dmYHis');
$sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR', $sql, 1, $explain_count);
MediaWiki\suppressWarnings();
$this->mLastResult = $stmt = oci_parse($this->mConn, $sql);
if ($stmt === false) {
$e = oci_error($this->mConn);
$this->reportQueryError($e['message'], $e['code'], $sql, __METHOD__);
return false;
}
if (!oci_execute($stmt, $this->execFlags())) {
$e = oci_error($stmt);
if (!$this->ignoreDupValOnIndex || $e['code'] != '1') {
$this->reportQueryError($e['message'], $e['code'], $sql, __METHOD__);
return false;
}
}
MediaWiki\restoreWarnings();
if ($explain_count > 0) {
return $this->doQuery('SELECT id, cardinality "ROWS" FROM plan_table ' . 'WHERE statement_id = \'' . $explain_id . '\'');
} elseif (oci_statement_type($stmt) == 'SELECT') {
return new ORAResult($this, $stmt, $union_unique);
} else {
$this->mAffectedRows = oci_num_rows($stmt);
return true;
}
}
示例4: read
/**
* Reads messages from the file in a given language and returns an array
* of AUTHORS, MESSAGES and possibly other properties.
*
* @param string $code Language code.
* @return array|bool False if the file does not exist
* @throws MWException if the file is not readable or has bad encoding
*/
public function read($code)
{
if (!$this->exists($code)) {
return false;
}
$filename = $this->group->getSourceFilePath($code);
$input = file_get_contents($filename);
if ($input === false) {
throw new MWException("Unable to read file {$filename}.");
}
if (!StringUtils::isUtf8($input)) {
throw new MWException("Contents of {$filename} are not valid utf-8.");
}
$input = UtfNormal::cleanUp($input);
try {
return $this->readFromVariable($input);
} catch (Exception $e) {
throw new MWException("Parsing {$filename} failed: " . $e->getMessage());
}
}