本文整理汇总了PHP中Bitrix\Main\Application::isUtfMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::isUtfMode方法的具体用法?PHP Application::isUtfMode怎么用?PHP Application::isUtfMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Application
的用法示例。
在下文中一共展示了Application::isUtfMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forSql
/**
* Escapes special characters in a string for use in an SQL statement.
*
* @param string $value Value to be escaped.
* @param integer $maxLength Limits string length if set.
*
* @return string
*/
function forSql($value, $maxLength = 0)
{
if ($maxLength <= 0 || $maxLength > 2000) {
$maxLength = 2000;
}
$value = substr($value, 0, $maxLength);
if (\Bitrix\Main\Application::isUtfMode()) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
// This one can crash php with segmentation fault on large input data (over 20K)
// https://bugs.php.net/bug.php?id=60423
if (preg_match_all('%(
[\\x00-\\x7E] # ASCII
|[\\xC2-\\xDF][\\x80-\\xBF] # non-overlong 2-byte
|\\xE0[\\xA0-\\xBF][\\x80-\\xBF] # excluding overlongs
|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte
|\\xED[\\x80-\\x9F][\\x80-\\xBF] # excluding surrogates
|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} # planes 1-3
|[\\xF1-\\xF3][\\x80-\\xBF]{3} # planes 4-15
|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2} # plane 16
)+%x', $value, $match)) {
$value = implode(' ', $match[0]);
} else {
return '';
}
//There is no valid utf at all
}
return str_replace("'", "''", $value);
}
示例2: convertEncodingToCurrent
public static function convertEncodingToCurrent($string)
{
$isUtf8String = self::detectUtf8($string);
$isUtf8Config = Application::isUtfMode();
$currentCharset = null;
$context = Application::getInstance()->getContext();
if ($context != null) {
$culture = $context->getCulture();
if ($culture != null && method_exists($culture, "getCharset")) {
$currentCharset = $culture->getCharset();
}
}
if ($currentCharset == null) {
$currentCharset = Configuration::getValue("default_charset");
}
if ($currentCharset == null) {
$currentCharset = "Windows-1251";
}
$fromCp = "";
$toCp = "";
if ($isUtf8Config && !$isUtf8String) {
$fromCp = $currentCharset;
$toCp = "UTF-8";
} elseif (!$isUtf8Config && $isUtf8String) {
$fromCp = "UTF-8";
$toCp = $currentCharset;
}
if ($fromCp !== $toCp) {
$string = self::convertEncoding($string, $fromCp, $toCp);
}
return $string;
}
示例3: array
$status = \Bitrix\MobileApp\Designer\Manager::updateConfig($app, $platform, $params);
break;
case "removePlatform":
$code = $_REQUEST["code"];
$platform = $_REQUEST["platform"];
$status = Bitrix\MobileApp\Designer\Manager::removeConfig($code, $platform);
break;
case "createPlatform":
$status = \Bitrix\MobileApp\Designer\Manager::addConfig($_REQUEST["code"], $_REQUEST["platform"], array());
break;
case "createApp":
$code = $_REQUEST["code"];
$createTemplate = $_REQUEST["createNew"] === "Y";
$bindTemplate = $_REQUEST["bindTemplate"] === "Y";
$fields = array("FOLDER" => $_REQUEST["folder"], "NAME" => $_REQUEST["name"]);
if (!\Bitrix\Main\Application::isUtfMode()) {
$fields = \Bitrix\Main\Text\Encoding::convertEncodingArray($fields, "UTF-8", SITE_CHARSET);
$code = \Bitrix\Main\Text\Encoding::convertEncoding($code, "UTF-8", SITE_CHARSET);
$templateName = \Bitrix\Main\Text\Encoding::convertEncoding($templateName, "UTF-8", SITE_CHARSET);
}
$result = \Bitrix\MobileApp\Designer\Manager::createApp($code, $fields);
//creating global config inside
if ($result == \Bitrix\MobileApp\Designer\Manager::IS_ALREADY_EXISTS) {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject(array("status" => "is_already_exists"));
die;
}
$status = $result == \Bitrix\MobileApp\Designer\Manager::SUCCESS;
if ($status) {
\Bitrix\MobileApp\Designer\Manager::copyFromTemplate($fields["FOLDER"], $code);
if ($bindTemplate) {
示例4: PrepareStrToJson
/**
* Converts string from site charset in utf-8 and returns it
*
* @param string $s
*
* @return string
*/
public static function PrepareStrToJson($s = '')
{
return Application::isUtfMode() ? $s : Encoding::convertEncoding($s, SITE_CHARSET, 'UTF-8');
}