示例#1
0
文件: Base.php 项目: protaskin/utf8
 /**
  * @dataProvider providerUtf8IsAsciiCtrl
  */
 public function testUtf8IsAsciiCtrl($ord, $rv)
 {
     $this->assertEquals(utf8_is_ascii_ctrl($ord), $rv);
 }
示例#2
0
文件: base.php 项目: protaskin/utf8
/**
 * Checks if a string contains only 7bit ASCII bytes with device control codes
 * omitted.
 *
 * The device control codes can be found on the second table here:
 * http://www.w3schools.com/tags/ref_ascii.asp
 *
 * @param  string $str The string to test
 * @return bool True if it's all ASCII without device control codes and false
 *              otherwise
 */
function utf8_only_ascii_ctrl($str)
{
    $len = strlen($str);
    for ($i = 0; $i < $len; $i++) {
        if (!utf8_is_ascii_ctrl(ord($str[$i]))) {
            return false;
        }
    }
    return true;
}