PHP
PHP 인코딩 감지
씨엔아이소프트
2019. 9. 18. 13:23
반응형
PHP 인코딩 확인 함수 mb_detect_encoding() 로 확인을 할 수 있다.
$string = "인코딩확인";
$encodelist = array('ASCII','UTF-8','UTF-16LE','WINDOWS-1252','EUC-KR');
$detectencoding = mb_detect_encoding($string , $encodelist );
if(strtoupper($detectencoding ) == 'UTF-8') {
echo 'UTF-8 입니다';
}
응용
mb_detect_encoding($str, 'auto'); // 자동 감지
mb_detect_encoding($str, 'ASCII,EUC-KR,UTF-8');
mb_detect_encoding($str, array('ASCII,EUC-KR','UTF-8')); // 배열
반응형