1: If the page is open garbled, don't worry, do not do any editing. Remember。
2: Then click the menu to Modify-"page Properties-" title/code
3: In the Code select Simplified Chinese (gb2321)
4: Click Reload-"OK"
Create a new Notepad (not a clipboard!) , and then copy the file that you want to read into this Notepad file and save it. Use the following code to read the Notepad file 1303275.txt: found that when the page is encoded as gb2312 all normal display. Changed to UTF8 code, the number is normal, Chinese characters for garbled, which also belong to the normal
<?php Tutorial
$file = fopen ("1303275.txt", "R");//read-only Open text file
while (! feof ($file))//When file does not end
{
$line =fgets ($file);//read one line to $line variable
Echo $line. <br/> ";
}
Fclose ($file);//Close text file
?>
The above method is more stupid but also solves the problem, below I provide a no matter what txt text will not disorderly solution.
/*
@params $str input character $type need to get the encoding
@author Long Line
*/
function Autoiconv ($str, $type = "Gb2312//ignore") {
$utf 32_big_endian_bom = Chr (0x00). Chr (0x00). Chr (0XFE). Chr (0xff);
$utf 32_little_endian_bom = Chr (0xff). Chr (0XFE). Chr (0x00). Chr (0x00);
$utf 16_big_endian_bom = Chr (0xFE). Chr (0xff);
$utf 16_little_endian_bom = Chr (0xff). Chr (0XFE);
$utf 8_bom = Chr (0xef). Chr (0XBB). Chr (0XBF);
$first 2 = substr ($str, 0, 2);
$first 3 = substr ($str, 0, 3);
$first 4 = substr ($str, 0, 3);
if ($first 3 = = $utf 8_bom) $icon = ' utf-8 ';
ElseIf ($first 4 = = $utf 32_big_endian_bom) $icon = ' utf-32be ';
ElseIf ($first 4 = = $utf 32_little_endian_bom) $icon = ' Utf-32le ';
ElseIf ($first 2 = = $utf 16_big_endian_bom) $icon = ' utf-16be ';
ElseIf ($first 2 = = $utf 16_little_endian_bom) $icon = ' Utf-16le ';
else {$icon = ' ASCII '; return $str;}
Return Iconv ($icon, $type, $STR);
}