1

So, I seem to have gotten some Mac Roman characters in my database, and because of my Encryption setup I convert everything to UTF-8 upon record fetch.

The current code we're using to try and fix this is:

if ( ! mb_check_encoding( $strDecrypted, 'utf-8' ) )
{
    $strDecrypted = @iconv( mb_detect_encoding( $strDecrypted ), 'UTF-8//TRANSLIT', $strDecrypted );
}

But this is giving the following error:

Error Message: iconv(): Detected an illegal character in input string

Any help would be greatly appreciated!

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
joshbrw
  • 33
  • 6
  • Don't rely on the result of `mb_detect_encoding()` to detect mac roman; [It is not one of the character sets tested for](http://php.net/manual/en/function.mb-detect-order.php). – Phylogenesis Jun 05 '15 at 12:39
  • Ah ok.. @Phylogenesis.. Is there any method you'd recommend for basically converting any character set into UTF-8? – joshbrw Jun 05 '15 at 12:42
  • If you know it's either one or the other character sets (Mac Roman or UTF8), you could just use `$strDecrypted = iconv('macintosh', 'UTF-8', $strDecrypted);` – Phylogenesis Jun 05 '15 at 12:47

0 Answers0