Beispiel #1
0
 /**
  * @dataProvider providerUtf8IsAsciiCtrl
  */
 public function testUtf8IsAsciiCtrl($ord, $rv)
 {
     $this->assertEquals(utf8_is_ascii_ctrl($ord), $rv);
 }
Beispiel #2
0
/**
 * 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;
}