php sets the encoding format method
- 2020-05-30 19:44:35
a. If you want to use gb2312, php should output header: header(" Content-Type: text/html; charset=gb2312"), static page added < meta http-equiv="Content-Type" content="text/html; charset=gb2312" > , the encoding format of all files is ANSI, which can be opened by notepad and saved as ANSI, overwriting the source files.
b. If you want to use the utf-8 encoding, php should output the following header: header(" Content-Type: text/html; charset= utf-8 "), static page added < meta http-equiv="Content-Type" content="text/html; charset=utf-8" > , all the files are encoded in utf-8.
Recently, it was necessary to use the iconv function to convert the captured utf-8 encoded page into gb2312, and it was found that only using the iconv function to transcode the captured data 1 would result in 1 less data for no reason. It made me depressed for a while. I checked the information on the Internet and realized that this is an bug of the iconv function. iconv makes an error converting the character "--" to gb2312. The solution is simple: add "//IGNORE", which is the second parameter of iconv function, after the code to be converted, as follows:
ignore means to ignore conversion errors. Without the ignore parameter, all strings following this character cannot be saved.