bootstrap.inc #777

the assumption is made that text is passed; here is an type checking version.

function drupal_validate_utf8($text) {

if (strlen($text) == 0) {
return TRUE;
}
if (!is_scalar($text)){
watchdog(WATCHDOG_ERROR,__FUNCTION__ . ': passed non scalar, ', array('text' => $text));
return FALSE;
} else {
return (preg_match('/^./us', $text) == 1);
}
}

The "Watchdog" line is optional -- as a d00b I don't know when/if error tracing is relevant to the way Drupal is coded -- but it helps me.

Comments

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.