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


PHP CM_Util::sanitizeUtf方法代碼示例

本文整理匯總了PHP中CM_Util::sanitizeUtf方法的典型用法代碼示例。如果您正苦於以下問題:PHP CM_Util::sanitizeUtf方法的具體用法?PHP CM_Util::sanitizeUtf怎麽用?PHP CM_Util::sanitizeUtf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CM_Util的用法示例。


在下文中一共展示了CM_Util::sanitizeUtf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _sanitizeRecord

 /**
  * @param array $formattedRecord
  * @return array
  */
 protected function _sanitizeRecord(array $formattedRecord)
 {
     array_walk_recursive($formattedRecord, function (&$value, $key) {
         if (is_string($value) && !mb_check_encoding($value, 'UTF-8')) {
             $value = CM_Util::sanitizeUtf($value);
         }
     });
     return $formattedRecord;
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:13,代碼來源:Fluentd.php

示例2: getQuery

 public function getQuery()
 {
     if ($this->_bodyQuery === null) {
         if ($this->_bodyEncoding == self::ENCODING_JSON) {
             $body = CM_Util::sanitizeUtf($this->getBody());
             if (!is_array($this->_bodyQuery = json_decode($body, true))) {
                 throw new CM_Exception_Invalid('Cannot extract query from body', CM_Exception::WARN, ['body' => $body]);
             }
         } elseif ($this->_bodyEncoding == self::ENCODING_FORM) {
             parse_str($this->getBody(), $this->_bodyQuery);
         } else {
             $this->_bodyQuery = array();
         }
     }
     return array_merge($this->_query, $this->_bodyQuery);
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:16,代碼來源:Post.php

示例3: setUri

 /**
  * @param string $uri
  * @throws CM_Exception_Invalid
  */
 public function setUri($uri)
 {
     $uriWithHost = $uri;
     if ('/' === substr($uriWithHost, 0, 1)) {
         $uriWithHost = 'http://host' . $uri;
     }
     if (false === ($path = parse_url($uriWithHost, PHP_URL_PATH))) {
         throw new CM_Exception_Invalid('Cannot detect path from url.', null, ['url' => $uriWithHost]);
     }
     if (null === $path) {
         $path = '/';
     }
     $this->setPath($path);
     if (false === ($queryString = parse_url($uriWithHost, PHP_URL_QUERY))) {
         throw new CM_Exception_Invalid('Cannot detect query from url.', null, ['url' => $uriWithHost]);
     }
     mb_parse_str($queryString, $query);
     $querySanitized = [];
     foreach ($query as $key => $value) {
         $key = CM_Util::sanitizeUtf($key);
         if (is_array($value)) {
             array_walk_recursive($value, function (&$innerValue) {
                 if (is_string($innerValue)) {
                     $innerValue = CM_Util::sanitizeUtf($innerValue);
                 }
             });
         } else {
             $value = CM_Util::sanitizeUtf($value);
         }
         $querySanitized[$key] = $value;
     }
     $this->setQuery($querySanitized);
     $this->setLanguageUrl(null);
     $this->_uri = $uri;
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:39,代碼來源:Abstract.php

示例4: testSanitizeUtf

 public function testSanitizeUtf()
 {
     $this->assertSame('?.', CM_Util::sanitizeUtf(pack("H*", 'c32e')));
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:4,代碼來源:UtilTest.php

示例5: _sanitizeRecord

 /**
  * @param array $formattedRecord
  * @return array
  */
 protected function _sanitizeRecord(array $formattedRecord)
 {
     $nonUtfBytesList = [];
     array_walk_recursive($formattedRecord, function (&$value, $key) use(&$nonUtfBytesList) {
         if (is_string($value) && !mb_check_encoding($value, 'UTF-8')) {
             $nonUtfBytesList[$key] = unpack('H*', $value)[1];
             $value = CM_Util::sanitizeUtf($value);
         }
     });
     if (!empty($nonUtfBytesList)) {
         $formattedRecord['loggerNotifications']['sanitizedFields'] = [];
         foreach ($nonUtfBytesList as $key => $nonUtfByte) {
             $formattedRecord['loggerNotifications']['sanitizedFields'][$key] = $nonUtfByte;
         }
     }
     return $formattedRecord;
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:21,代碼來源:MongoDb.php


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