strspn et les caractères UTF-8
<?php
$allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
"abcdefghijklmnopqrstuvwxyz".
"éèàïùçàÉÈÀÏÙÇÀ+.-_'@ \r\n".
"0123456789";
preg_match('/^['.$allowedChars.']+/u', $value, $matches);
if (count ($matches))
{
$pos = mb_strlen ($matches[0]);
$error = sprintf (
_("Invalid character provided : '%s' (position %d)"),
mb_substr ($values["visitorNames"], $pos, 1), $pos);
}