Skip to content

2009.07.18 06:13

PHP 언어디코딩

조회 수 11537 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

php에서 UTF-8을 EUC-KR로 혹은 base64를 euc-kr 이런걸로 바꿔야할 경우가 종종있습니다.

iconv로 바꾸면 된다고들 하시는데 iconv는 짧은 단어만 바꿀때는 강력한데 길어지면 힘들어하더군요..

iconv("UTF-8", "EUC-KR", "동수야놀자"); //euc-kr
mb_convert_encoding("동수야 놀자","EUC-KR", "UTF-8"); //euc-kr

위에 두 함수 둘다 같은 결과를 뱉어냅니다..

그래도 좀 더 길어진 문자열이라면 상황은 다르죠... iconv는 결과를 못내줍니다.

웹메일의 본문 사용시에 mb_conver_encoding() 함수를 써봤는데 유용하더라구요..

mb_convert_encoding()함수는 변수도 " " 을 붙여합니다.

그다음 소개 해드릴건 mb_detect_encoding() 함수인데 이 함수는 현재 받아온 인자값이

어떤타입의 인코딩으로 되어있는지 보여주는겁니다.

예제) 아래 소스는 utf-8일경우 euc-kr로 바꾸는 소스입니다.

  if('utf-8' == strtolower(mb_detect_encoding($fromdecode, 'euc-kr, utf-8')))
    {
     $From = mb_convert_encoding("$fromdecode","EUC-KR", "UTF-8");
    }


  1. Freetds 설치 참고 (sybase)

    Date2009.06.04 ByADMINPLAY Views10721
    Read More
  2. PHPMyAdmin 오류조치법 The mbstring PHP extension was ...

    Date2009.01.20 ByADMINPLAY Views10865
    Read More
  3. php.ini 세션유지 시간 설정

    Date2009.06.04 ByADMINPLAY Views10970
    Read More
  4. SENDMAIL SPAMASSASSIN 관리 local.cf

    Date2009.07.18 ByADMINPLAY Views11405
    Read More
  5. PHP 컴파일하고 Make 할때 lltdl을 찾을 수 없다면서 중지...

    Date2009.06.01 ByADMINPLAY Views11499
    Read More
  6. PHP 언어디코딩

    Date2009.07.18 ByADMINPLAY Views11537
    Read More
  7. Ubuntu 7.04 Server 에 Zend Optimizer 3.2.8 설치하기!

    Date2009.07.19 ByADMINPLAY Views11642
    Read More
  8. php 5.1.4 인데 ZipArchive() 사용하기 --enable-zip

    Date2009.06.03 ByADMINPLAY Views13304
    Read More
  9. [PHP] 정규 표현식 정리

    Date2009.06.29 ByADMINPLAY Views14900
    Read More
  10. PHP - eAccelerator 설치

    Date2009.08.03 ByADMINPLAY Views15018
    Read More
  11. 4.1.0이상 php 버전에서 register_globals = Off 일때 기...

    Date2010.01.09 ByADMINPLAY Views15440
    Read More
  12. register_globals = off 란?

    Date2010.01.09 ByADMINPLAY Views15551
    Read More
  13. PEC HTTP Setup

    Date2009.12.31 ByADMINPLAY Views15942
    Read More
  14. php컴파일에러(flex) configure: error: cannot find out...

    Date2009.08.08 ByADMINPLAY Views16112
    Read More
  15. PHPMyAdmin - blowfish_secret 해결방법

    Date2009.09.08 ByADMINPLAY Views16504
    Read More
  16. Warning: flock(): supplied argument is not a valid str...

    Date2009.09.09 ByADMINPLAY Views16768
    Read More
  17. php에서 curl 설치하기

    Date2009.06.01 ByADMINPLAY Views16848
    Read More
  18. PHP FreeTDS 사용 (MS-SQL)

    Date2010.01.05 ByADMINPLAY Views16948
    Read More
  19. php세션정리

    Date2009.09.19 ByADMINPLAY Views17198
    Read More
  20. pear 1.9 업그레이드 및 패치설치

    Date2009.12.31 ByADMINPLAY Views17326
    Read More
Board Pagination Prev 1 2 3 Next
/ 3

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234