本文整理汇总了PHP中text::strip_ascii_ctrl方法的典型用法代码示例。如果您正苦于以下问题:PHP text::strip_ascii_ctrl方法的具体用法?PHP text::strip_ascii_ctrl怎么用?PHP text::strip_ascii_ctrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text
的用法示例。
在下文中一共展示了text::strip_ascii_ctrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean
/**
* Transliterate UTF8 text to lowercase 7bit ASCII, 0-9a-z
*
* @param string $str
* @return string
*/
public static function clean($str)
{
$str = mb_strtolower(text::strip_ascii_ctrl($str));
if (!text::is_ascii($str)) {
$str = strtolower(text::transliterate_to_ascii($str));
}
if (!text::is_ascii($str)) {
$str = text::strip_non_ascii($str);
}
return $str;
// return strtolower(iconv(Kohana::CHARSET, 'ASCII//TRANSLIT//IGNORE', $str));
}
示例2: strip_ascii_ctrl
/**
* Tests the text::strip_ascii_ctrl() function.
* @dataProvider strip_ascii_ctrl_provider
* @group core.helpers.text.strip_ascii_ctrl
* @test
*/
public function strip_ascii_ctrl($str, $expected_result)
{
$result = text::strip_ascii_ctrl($str);
$this->assertEquals($expected_result, $result);
}
示例3: clean
/**
* Recursively cleans arrays, objects, and strings. Removes ASCII control
* codes and converts to UTF-8 while silently discarding incompatible
* UTF-8 characters.
*
* @param string string to clean
* @return string
*/
public static function clean($str)
{
if (is_array($str) or is_object($str)) {
foreach ($str as $key => $val) {
// Recursion!
$str[Input::clean($key)] = Input::clean($val);
}
} elseif (is_string($str) and $str !== '') {
// Remove control characters
$str = text::strip_ascii_ctrl($str);
if (!text::is_ascii($str)) {
// Disable notices
$ER = error_reporting(~E_NOTICE);
// iconv is expensive, so it is only used when needed
$str = iconv(Kohana::CHARSET, Kohana::CHARSET . '//IGNORE', $str);
// Turn notices back on
error_reporting($ER);
}
}
return $str;
}