Is there only two kinds of coding in case I am safe with this function?
In the case of only GBK and utf-8 two kinds of coding, have the following function to determine whether the encoding format is safe?
PHP Code
function checkencoding ($str) { $s = json_encode ($str); $c = substr ($s, 0,7); if ($c = = ' "\ufeff ') return ' utf-8 ';
------Solution--------------------
How could this be the right one?
abcde0123456789 in the case of GBK and Utf-8, the byte code is exactly the same
------Solution--------------------
Unsafe, even Notepad has a BOM head trap.
In fact, it's not safe to use any of your options.
------Solution--------------------
mb_check_encoding function not?
------Solution--------------------
Csdn do bad enough, want to edit the post is not.
Enclosed is a link found: http://stackoverflow.com/questions/1037363/how-to-check-the-charset-of-string
------Solution--------------------
discuss
Csdn do bad enough, want to edit the post is not.
Enclosed is a link found: http://stackoverflow.com/questions/1037363/how-to-check-the-charset-of-string