Search code examples
phpmysqlutf8-decode

encode or decode string from mysql using php


In my db I have a field value looking like this:

ΜΑΚΑΡΙΟΥ Γ\'

I think it must be Greek chars inserted when I didn't have set UTF-8 for my db (I think I was using the default Latin 1).

Is there a way to get the actual characters?

Thank you


Solution

  • Not sure, Try this :

    $str = "ΜΑΚΑΡΙΟΥ Γ\'";
    $val = iconv(mb_detect_encoding($str), "UTF-8", $str);
    echo $val;