출처: http://tester.tistory.com/42
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);
$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;
}
'HTML' 카테고리의 다른 글
★ php substr ★ [php함수] strpos(),strrpos(),strrchr(),strstr(),substr() (0) | 2011.05.10 |
---|---|
★ php substr ★ PHP 함수 substr() 사용법 (0) | 2011.05.10 |
★ php substr ★ [PHP] 문자열 관련 함수 (0) | 2011.05.10 |
★ php substr ★ PHP 문자열 처리 함수 (0) | 2011.05.10 |
★ php substr ★ php 인코딩 iconv (0) | 2011.05.10 |