Topic: Question on functions
Functions:
//
// Equivalent to htmlspecialchars(), but allows &#[0-9]+ (for unicode)
//
function pun_htmlspecialchars($str)
{
$str = preg_replace('/&(?!#[0-9]+;)/s', '&', $str);
$str = str_replace(array('<', '>', '"'), array('<', '>', '"'), $str);
return $str;
}
//
// Equivalent to strlen(), but counts &#[0-9]+ as one character (for unicode)
//
function pun_strlen($str)
{
return strlen(preg_replace('/&#([0-9]+);/', '!', $str));
}
Looking only at cases where the use UTF-8, I understand it correctly? Or even if use for example Win-1251, they still have meaning (such as if the text is sent in UTF-8) or both?
Tnx!