Fix encoding detection for php before 5.4

This should fix the issues with UTF encoded footers and also make the preg_match_all call compatible with php5.3, see https://github.com/antonraharja/playSMS/pull/160 for more information