Search code examples
phpmysqliutf8mb4

How to retrive Data from sql server databse using unicode language to urdu


mysqli_query($con,"SET CHARACTER SET 'utf8'");

mysqli_set_charset($con,'utf8mb4');

Using select query i get

 :جدیث: ØÂ-ضورصلیعلی۠وسلم Ù†Û’ ÙÂرمایا:

I want to this format

enter image description here


Solution

  • The text has been mangled twice.

    1. start with رص
    2. treat that as if it were erroneously converted through latin1, I get رص. (The "Mojibake" of that is what is in step 1.)
    3. Again, doing an un-Mojibake, I see رص, which is probably part of that png. That's Arabic REH and SAD; does that sound likely?

    See "Mojibake" in Trouble with UTF-8 characters; what I see is not what I stored for the likely causes. But, then, realize that the mangling was done twice!

    Dig through how the text is processed. But keep in mind that there are at least 2 sequential mistakes. Perhaps even copying the data from one table/database/system to another, with each one doing its own Mojibake?

    (I have been chasing charset problems for years; this is, I think, a new scenario to me!)

    Undoing one stage:

    CONVERT(BINARY(CONVERT('رص' USING latin1)) USING utf8mb4) --> `رص`
    

    (Sorry if I have lost the right-to-left vs left-to-right.)

    But you need to avoid latin1 at all stages. mysqli_set_charset and <meta> are only two parts of the picture.

    Longer string:

    `جدیث: ØÂ-ضو` --> `جدیث` --> `جدیث`