In the Unicode state in the browser, I see such a garbled code. I tried to use PHP for decoding and failed... but the simple file encoding conversion, it is successful, the step is like this: Keep the content in the Western (ISO8859-1) format open with a browser, set the encoding to gb2312... in the Unicode state in the browser, I see such a garbled code. I tried to use PHP for decoding and failed... however, simple file encoding conversion is successful. The steps are as follows:
-
Keep content in Western (ISO8859-1) Format
-
Open it in the browser and set the encoding to GB2312.
The problem is that if my file must be UTF-8 encoded, how can I decode the Garbled text?
The garbled content is: '2» öª µà Õ â n {µäö÷» ú¡ £'
Reply content:
In the Unicode state in the browser, I see such a garbled code. I tried to use PHP for decoding and failed... however, simple file encoding conversion is successful. The steps are as follows:
-
Keep content in Western (ISO8859-1) Format
-
Open it in the browser and set the encoding to GB2312.
The problem is that if my file must be UTF-8 encoded, how can I decode the Garbled text?
The garbled content is: '2» öª µà Õ â n {µäö÷» ú¡ £'
PHPExtensioniconvIs used for encoding conversion.
The transcoding method is as follows:
$text = iconv("ISO-8859-1", "UTF-8", $text)
The answer is not that simple. I just tried it. The correct solution is as follows:
var_dump($str = iconv("UTF-8", "ISO-8859-1", '²»ÖªµÀÕâÑùµÄÖ÷»ú¡£'));var_dump($str = iconv("GB18030", "UTF-8", $str));
First to decode as a ISO-8859-1, but this state is still garbled, so you have to convert to GB18030, and then restore to the UTF-8 (with the file where the matching encoding ).