Skip to content

Instantly share code, notes, and snippets.

@ocombe
Last active December 18, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocombe/5771995 to your computer and use it in GitHub Desktop.
Save ocombe/5771995 to your computer and use it in GitHub Desktop.
Detect text encoding in php
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