当前位置: 首页>>代码示例>>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;未经允许,请勿转载。