When writing PHP code and copying code from another file, garbled characters are generated due to different characters in the code.
Some interesting solutions are captured from the Internet and reproduced.
Using new string (Str. getbytes ("UTF-8"), "GBK"), UTF-8 cannot be converted to GBK
Urldecoder. Decode (urlencoder. encode (STR, "GBK"), "GBK "),
STR is a UTF-8 string, and the result is converted to GBK.
The stupid method is to use Dreamweaver for conversion. If one or two files are okay, the 100 or 200 files will be finished. So the best method is to directly use the code conversion software. The software I use is convertz. It seems that this software has not been updated since it was developed n years ago, but it is quite useful.
This software is free of installation, double-click convertz.exe. After the program is started, it will automatically hide to the top of the desktop, open the files you need, as shown in
Select the folder in which you want to convert the template. files ending with ".htm,.html" and ".txt" in the folder will appear in the view. Do not forget to set the directory of the converted document in the destination option. At this time, the advanced options may not have the conversion mode you need. For example, if you want to convert UTF-8 to GBK, click the advanced Options button and there will be the following options:
Select the input format and output format. Hide the advanced Options button and add the file you want to convert to the file list.
OK. Click Start conversion. The conversion will be completed soon.
Note: When the GBK template is converted to UTF-8, some punctuation points cannot be converted, and these GBK-encoded punctuation points cannot be displayed on foreign computers. Therefore, some files need to replace some unconvertible items in batches. Similarly, the Chinese website uses the uft-8 template is not pure UTF-8, want to translate into English template use do not forget which punctuation and symbols need to be modified.