当前位置: 首页>>代码示例>>PHP>>正文


PHP UTF8::strip_ascii_ctrl方法代码示例

本文整理汇总了PHP中UTF8::strip_ascii_ctrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::strip_ascii_ctrl方法的具体用法?PHP UTF8::strip_ascii_ctrl怎么用?PHP UTF8::strip_ascii_ctrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTF8的用法示例。


在下文中一共展示了UTF8::strip_ascii_ctrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clean

 public static function clean($var, $charset = NULL)
 {
     if (!$charset) {
         // Use the application character set
         $charset = JsonApiApplication::$charset;
     }
     if (is_array($var) or is_object($var)) {
         foreach ($var as $key => $val) {
             // Recursion!
             $var[UTF8::clean($key)] = UTF8::clean($val);
         }
     } elseif (is_string($var) and $var !== "") {
         // Remove control characters
         $var = UTF8::strip_ascii_ctrl($var);
         if (!UTF8::is_ascii($var)) {
             // Temporarily save the mb_substitute_character() value into a variable
             $mb_substitute_character = mb_substitute_character();
             // Disable substituting illegal characters with the default '?' character
             mb_substitute_character("none");
             // convert encoding, this is expensive, used when $var is not ASCII
             $var = mb_convert_encoding($var, $charset, $charset);
             // Reset mb_substitute_character() value back to the original setting
             mb_substitute_character($mb_substitute_character);
         }
     }
     return $var;
 }
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:27,代码来源:UTF8.php

示例2: clean

 /**
  * Recursively cleans arrays, objects, and strings. Removes ASCII control
  * codes and converts to the requested charset while silently discarding
  * incompatible characters.
  *
  * @param   mixed  $str
  * @return  string
  */
 public static function clean($str)
 {
     if (is_array($str) || is_object($str)) {
         foreach ($str as $key => $val) {
             $str[$key] = self::clean($val);
         }
     } else {
         if (is_string($str) && $str !== '') {
             $str = mb_strtolower(UTF8::strip_ascii_ctrl($str));
             if (!UTF8::is_ascii($str)) {
                 $str = strtolower(self::transliterate_to_ascii($str));
             }
             if (!UTF8::is_ascii($str)) {
                 $str = UTF8::strip_non_ascii($str);
             }
         }
     }
     return $str;
 }
开发者ID:anqh,项目名称:core,代码行数:27,代码来源:text.php

示例3: clean

 /**
  * Recursively cleans arrays, objects, and strings. Removes ASCII control
  * codes and converts to the requested charset while silently discarding
  * incompatible characters.
  *
  *     UTF8::clean($_GET); // Clean GET data
  *
  * @param   mixed   $var        variable to clean
  * @param   string  $charset    character set, defaults to Kohana::$charset
  * @return  mixed
  * @uses    UTF8::clean
  * @uses    UTF8::strip_ascii_ctrl
  * @uses    UTF8::is_ascii
  */
 public static function clean($var, $charset = 'utf-8')
 {
     if (is_array($var) or is_object($var)) {
         foreach ($var as $key => $val) {
             // Recursion!
             $var[UTF8::clean($key)] = UTF8::clean($val);
         }
     } elseif (is_string($var) and $var !== '') {
         // Remove control characters
         $var = UTF8::strip_ascii_ctrl($var);
         if (!UTF8::is_ascii($var)) {
             // Disable notices
             $error_reporting = error_reporting(~E_NOTICE);
             $var = mb_convert_encoding($var, $charset, $charset);
             // Turn notices back on
             error_reporting($error_reporting);
         }
     }
     return $var;
 }
开发者ID:doorframework,项目名称:core,代码行数:34,代码来源:UTF8.php

示例4: test_strip_ascii_ctrl

 /**
  * Tests UTF8::strip_ascii_ctrl
  *
  * @test
  * @dataProvider provider_strip_ascii_ctrl
  */
 public function test_strip_ascii_ctrl($input, $expected)
 {
     $this->assertSame($expected, UTF8::strip_ascii_ctrl($input));
 }
开发者ID:azuya,项目名称:Wi3,代码行数:10,代码来源:UTF8Test.php


注:本文中的UTF8::strip_ascii_ctrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。