Class it_html:

/**
 * Shortcut: return htmlspecialchars($string) and encode forbidden characters 80-9f if latin1 is output
 * @param $string String to encode with htmlspecialchars()
 * @return htmlspecialchars($string)
 */
static function Q($string)
{
    $string = @strval($string);
    if (preg_match('/[<>&"\x00-\x08\x0a-\x0c\x0e-\x1f\x80-\xff]/', $string)) # WARNING: copy/pasted to _tag()
    {
        $charset = $GLOBALS['it_html']->p['charset'] ?: ini_get('default_charset');
        if ($GLOBALS['debug_utf8check'] && $charset == "utf-8")
            $string = it::any2utf8($string, "error in Q()");

        $origstring = $string;
        $string = @htmlspecialchars(self::_cleanup($string, $charset), ENT_COMPAT, $charset);
        if ($string === "" && $origstring)
            it::error("invalid utf-8 '$origstring'");
    }

    return $GLOBALS['debug_q'] && $string ? "<span style='background:#8FF'>$string</span>" : $string;
}