textencodingarabicmojibake

How do I reverse back corrupted text to Arabic


The text file was written in Arabic originally, then when I moved the file to an external SSD, then to another device it turned gibberish.(like this):

---áÇÊÊÓÑÚ ÈÇí ÔÆ
---ÇáÎÑæÌ ãä ÇáãÔÇßá ÈÐßÇÁ
---ÝßÑ ÈÐßÇÁ

I tried my best changing the encoding but nothing happened.

Is there a way to get it back?


Solution

  • It depends on your operating system. This looks like it was original encoded in CP1256 and then interpreted as Latin-1. On a unix-like system, you can use iconv to convert it:

    %  echo 'áÇÊÊÓÑÚ ÈÇí ÔÆ' | iconv -t latin1 | iconv -f cp1256
    لاتتسرع باي شئ
    

    This takes the UTF-8 (which is what you pasted here) and converts it to Latin-1. It then reinterprets it as if it were CP1256 and outputs it as UTF-8.

    It is also possible that your old system was configured in CP1256 and your new system is configured as Latin-1. If that's the case, you can likely reconfigure your new system to read in CP1256. (How to do that completely depends on your setup, and may not be possible for all systems.)