This is what I've found in the Kohana3 validator rules:
public static function digit($str, $utf8 = FALSE)
{
if ($utf8 === TRUE)
{
return (bool) preg_match('/^\pN++$/uD', $str);
}
else
{
return (is_int($str) AND $str >= 0) OR ctype_digit($str);
}
}
Can someone give an example when passing $utf8
parameter as true
and false
can give different results (to be precise - false positives for $utf8 == false
)?
From what I remember - digits are ascii-safe characters and none of utf-8 characters may be confused with them.
PS: even more detailed - is it possible to fool this check and pass something that in UTF-8 would look not like a number, but would pass the check with $utf-8 == false