foreach ($a[1] as $unicode) { $num = hexdec($unicode); $str = ''; // UTF-16(32) number to UTF-8 string if ($num < 0x80) { $str = chr($num); } else { if ($num < 0x800) { $str = chr(0xc0 | ($num & 0x7c0) >> 6) . chr(0x80 | $num & 0x3f); } else { if ($num < 0x10000) { $str = chr(0xe0 | ($num & 0xf000) >> 12) . chr(0x80 | ($num & 0xfc0) >> 6) . chr(0x80 | $num & 0x3f); } else { $str = chr(0xf0 | ($num & 0x1c0000) >> 18) . chr(0x80 | ($num & 0x3f000) >> 12) . chr(0x80 | ($num & 0xfc0) >> 6) . chr(0x80 | $num & 0x3f); } } } $str = iconv("UTF-8", "{$encoding}//IGNORE", $str); $url = str_replace('%u' . $unicode, $str, $url); } return urldecode($url); } if (isset($_GET['q'])) { //$q=html_entity_decode($_GET['q'], ENT_NOQUOTES,'UTF-8'); $q = unicodeUrlDecode($_GET['q'], "UTF-8"); $query = "SELECT name FROM ref_city WHERE lower(name) LIKE '{$q}%' ORDER BY name LIMIT 20 "; $query = @mysql_query($query); while (true == ($row = @mysql_fetch_array($query))) { echo iconv('utf-8', 'windows-1251', $row['name']) . "\r\n"; } }
$str = chr(0xc0 | ($num & 0x7c0) >> 6) . chr(0x80 | $num & 0x3f); } else { if ($num < 0x10000) { $str = chr(0xe0 | ($num & 0xf000) >> 12) . chr(0x80 | ($num & 0xfc0) >> 6) . chr(0x80 | $num & 0x3f); } else { $str = chr(0xf0 | ($num & 0x1c0000) >> 18) . chr(0x80 | ($num & 0x3f000) >> 12) . chr(0x80 | ($num & 0xfc0) >> 6) . chr(0x80 | $num & 0x3f); } } } $str = iconv("UTF-8", "{$encoding}//IGNORE", $str); $url = str_replace('%u' . $unicode, $str, $url); } return urldecode($url); } if (isset($_GET['q'])) { $q = unicodeUrlDecode($_GET['q'], "cp1251"); $q = trim(strtolower(SQL::slashes($q))); $condition = ''; if ($q) { if ($words = Rumor::getAllForms($q)) { $or = array(); foreach ($words as $w) { $or[] = "i.name LIKE '%" . $w . "%'"; } $condition .= " AND (" . implode(' OR ', $or) . ")"; } else { $condition .= " AND (i.name LIKE '%" . SQL::slashes($q) . "%')"; } } $query = "SELECT i.name,price \r\n\t\tFROM sc_shop_item i\r\n\t\t\t\r\n\t\tWHERE price>0 AND in_stock>0"; if (isset($_GET['m']) && $_GET['m'] == 'all') {