mb_check_encoding() ã®å é¨å¦ç
åèã¾ã§ã«ãmb_check_encoding() ãå
é¨ã§ä½ããã¦ãããã«ã¤ãã¦æ¸ãã¦ããã¾ãã
mb_check_encoding() 㯠mb_convert_encoding() ã§ç¬¬2å¼æ°ã¨ç¬¬3å¼æ°ã«åãæåã³ã¼ããæå®ããå ´åã¨åãå¦çããå
ã®æååã¨ãå¤æå¾ã®æååãåããã©ãã㧠TRUE/FALSE ã®å¤å®ãè¡ãã¾ãã
mb_convert_encoding() ã®å
é¨ã§ã¯ãå¤ææã«ã¦ãã³ã¼ãæååã«å¤æãããã¨ããããå
ã®æåã³ã¼ãã«æ»ããæã«å
ã®æååã¨éããã¨ãããã¾ãããã®ãããmb_check_encoding() ã§ã¯ãTRUE ãè¿ãå¿
è¦ãããæåå㧠FALSE ãè¿ããã¨ãããã¾ãã
å®éã«ã¯ã以ä¸ã®2ã¤ã¯åçã®çµæã«ãªãã¾ã(PHP 5.2.0 以éãæ£ç¢ºã«ã¯ PHP 5.2.7 以é)ã
<?php $result = $str === mb_convert_encoding( $str, 'SJIS', 'SJIS' ); //1 $result = mb_check_encoding( $str, 'SJIS' ); //2
mb_check_encoding() ã¯ä»¥ä¸ã®ããã«ãå¤ãã®æ³¨æäºé ãããã¾ãã
- PHP 5.3.0 ã§ã¯ UTF-8 ã®åæ±ããå³ãããªã£ã¦ãã(ãµãã²ã¼ããã¢ã«ç¸å½ããé å㯠FALSE ãè¿ãããã«ãªã£ã)ãã ããPHP 5.2.x ã¯å¯¾è±¡å¤
- PHP 5.2.9 㧠SJIS ããã³ãSJIS-win ã§ä¸é¨ã®ä¸æ£ãªæååã TRUE ã«ãªãåé¡ãä¿®æ£ããã¦ãã
- PHP 5.2.7 ããåã®ãã¼ã¸ã§ã³ã§ã¯ã$str ã« NULL ãã¤ããå«ã¾ãã¦ããå ´åãä¸æ£ãªæååã§ã mb_check_encoding() ã TRUE ãè¿ããã¨ããã
- PHP 4.4.3 - 4.4.4ãPHP 5.1.3 - 5.2.0 ã§ã¯ãUTF-8 ã®å¤å®ã§å¸¸ã« TRUE ãè¿ãã¨ããåé¡ããã
- PHP 4.4.2 以åãPHP 5.1.2 以åã®ãã¼ã¸ã§ã³ã«ã¯ mb_check_encoding() ã¯å®è£ ããã¦ããªã
- PHP 5.2.1 ã§ã¯ãæåã³ã¼ãå¤æã«ä¸é¨ä¿®æ£ããããmb_check_encoding( "\x8f\xa2\xb7", "eucJP-win" ) ãªã©ãPHP 5.2.0 以åã§ã¯ãTRUEãPHP 5.2.1 以éã§ã¯ FALSE ã«ãªã£ãæåããã
ä¿®æ£(2009.09.21): PHP 5.3.0 ã¯ãªãªã¼ã¹ããã¾ããã®ã§ãè¨è¿°ãå°ãä¿®æ£ãã¾ããã
ã¾ã ç¶ãã¾ãããã¨ãISO-2022-JP 㨠UTF-16 ã«ã¤ãã¦æ¸ãäºå®ã§ãã
ç¶ããæ¸ãã¾ããã