當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::isUtfMode方法代碼示例

本文整理匯總了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);
    }
開發者ID:Satariall,項目名稱:izurit,代碼行數:36,代碼來源:oraclesqlhelper.php

示例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;
 }
開發者ID:ASDAFF,項目名稱:bxApiDocs,代碼行數:32,代碼來源:encoding.php

示例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) {
開發者ID:Satariall,項目名稱:izurit,代碼行數:31,代碼來源:mobile_designer.php

示例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');
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:11,代碼來源:mobile.php


注:本文中的Bitrix\Main\Application::isUtfMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。