}
$path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
- if (!StringUtil::isASCII($path) && !StringUtil::isUTF8($path)) {
+ if (!StringUtil::isUTF8($path)) {
$path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
}
$path = FileUtil::removeLeadingSlash($path);
*/
protected function parseKeywords($keywordString) {
// convert encoding if necessary
- if (!StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
+ if (!StringUtil::isUTF8($keywordString)) {
$keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
}
* @return boolean
*/
public static function isUTF8($string) {
- /*return preg_match('/^(
+ return preg_match('/^(
[\x09\x0A\x0D\x20-\x7E]* # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$/x', $string);
- */
- return preg_match('/(
- [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
- | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
- | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
- | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
- | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
- | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
- | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
- )/x', $string);
}
/**
public static function getUserAgent() {
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$userAgent = $_SERVER['HTTP_USER_AGENT'];
- if (!StringUtil::isASCII($userAgent) && !StringUtil::isUTF8($userAgent)) {
+ if (!StringUtil::isUTF8($userAgent)) {
$userAgent = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $userAgent);
}
}
// fix encoding
- if (!StringUtil::isASCII($REQUEST_URI) && !StringUtil::isUTF8($REQUEST_URI)) {
+ if (!StringUtil::isUTF8($REQUEST_URI)) {
$REQUEST_URI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $REQUEST_URI);
}