티스토리 뷰
PHP에서 iconv 사용가능 하여야 합니다.
function tostring($text) { //return iconv('UTF-16LE', 'UTF-8', chr(hexdec(substr($text[1], 2, 2))).chr(hexdec(substr($text[1], 0, 2)))); return iconv('UTF-16LE', 'UHC', chr(hexdec(substr($text[1], 2, 2))).chr(hexdec(substr($text[1], 0, 2)))); } function urlutfchr($text){ return rawurldecode(preg_replace_callback('/%u([[:alnum:]]{4})/', 'tostring', $text)); }
처리할 문서가 charset euc-kr 일경우 함수 tostring 에서 iconv 2번째인자를 "UHC" 로
utf8 일경우 "UTF-8"로 지정한다.
예)
$escapeString = "%uC548%uB155%uD558%uC138%uC694"; // 자스에서 "안녕하세요"를 escape 한 문자열
$unEscapeString = urlutfchr($escapeString);
echo $unEscapeString;
// 출력결과
// 안녕하세요
'웹프로그래밍 > PHP' 카테고리의 다른 글
PHP Snoopy Class 사이트 긁어오기 (0) | 2012.03.06 |
---|---|
windows iis php unlink() permission denied (0) | 2010.09.05 |
[PHP] PHP로 HTML Table Parse (0) | 2010.05.27 |
SQL Server Driver For PHP (0) | 2010.01.06 |
IIS에 설치한 PHP로 MS-SQL 처리 (0) | 2010.01.04 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- nginx
- mssql
- ASP
- git
- Wordpress
- PHP
- Mac
- sencha touch
- Debug
- JSON
- laravel
- Prototype
- 워드프레스
- iphone
- CSS
- 한글
- iis
- IOS
- Docker
- nodejs
- centos
- 안드로이드
- Android
- IE
- classic asp
- Linux
- macos
- javascript
- JQuery
- API
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
글 보관함