Created
December 11, 2011 13:38
-
-
Save inogo/1460667 to your computer and use it in GitHub Desktop.
simple encoding detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function detect_encoding($string) | |
{ | |
foreach (array('UTF-8', 'Windows-1251') as $enc) { | |
$sample = @iconv($enc, $enc, $string); | |
if (md5($sample) == md5($string)) | |
return $enc; | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment