사이트 내 전체검색
PHP
파라미터가 UTF-8 인지 검사 , 문자열 인코딩 검사함수
로빈아빠
https://cmd.kr/php/846 URL이 복사되었습니다.

본문

처음 시도 php 함수 mb_detect_encoding으로 검사

파라미터에 대해서 인코딩방식이 어떤 것인지 판별하여 Return해준다.

string mb_detect_encoding ( string $str [, mixed $encoding_list= mb_detect_order() [, bool $strict= false ]] )

예제


사용은 대충 이런식으로 하게 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<code>/* Detect character encoding with current detect_order */
echo mb_detect_encoding($str);
 
/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
echo mb_detect_encoding($str, "auto");
 
/* Specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win");
 
/* Use array to specify encoding_list  */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo mb_detect_encoding(

댓글목록

등록된 댓글이 없습니다.

PHP
871 (3/18P)

Search

Copyright © Cmd 명령어 18.219.103.183