Last active
December 18, 2015 10:59
-
-
Save ocombe/5771995 to your computer and use it in GitHub Desktop.
Detect text encoding in php
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
public function findEncoding($str) { | |
$tab = array("UTF-8", "ASCII", "ISO-8859-1"); | |
foreach ($tab as $i) { | |
foreach ($tab as $j) { | |
$chain .= " [iconv('$i','$j','$str'): " . iconv($i, $j, "$str") . "] "; | |
} | |
} | |
return $chain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment