перекодирование UTF8 в русский после отработки JS

nagash

Guest
перекодирование UTF8 в русский после отработки JS

(скиньте в избранное плз)
перекодирование UTF8 в русский после отработки JS
utf8 javascript decode urlencode

PHP:
function utf8RawUrlDecode ($source) { 
	$decodedStr = ''; 
	$pos = 0; 
	$len = strlen ($source); 
	while ($pos < $len) { 
		$charAt = substr ($source, $pos, 1); 
		if ($charAt == '%') { 
			$pos++; 
			$charAt = substr ($source, $pos, 1); 
			if ($charAt == 'u') { 
				// we got a unicode character 
				$pos++; 
				$unicodeHexVal = substr ($source, $pos, 4); 
				$unicode = hexdec ($unicodeHexVal);
				$entity = "&#". $unicode . ';'; 
				$decodedStr .= utf8_Encode ($entity); 
				$decodedStr .= chr($unicode-848);
				$pos += 4; 
			} 
			else { 
				// we have an escaped ascii character 
				$hexVal = substr ($source, $pos, 2); 
				$decodedStr .= chr (hexdec ($hexVal)); 
				$pos += 2; 
			} 
		} 
		else { 
			$decodedStr .= $charAt; 
			$pos++; 
		} 
	} 
	return $decodedStr; 
}
 
Сверху