Solution for bat to execute php Chinese garbled code: 1. Use the Notepad that comes with the Windows operating system platform to open the script file; 2. Click the menu [File] - [Save As] operation; 3. Select ANSI encoding Save; 4. Declare the code page change in the original bat script file.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if bat executes Chinese garbled code in php?
bat batch script solution to Chinese garbled characters
bat batch script is as follows
@echo off echo hello,world. echo 你好,中国 pause
When CMD executes the script, Chinese garbled characters
By default, in the bat script file, if the Chinese is not ANSI encoding, it will appear Garbled characters. Therefore, you can use the Notepad that comes with the Windows operating system platform to open the script file, click the menu [File] - [Save As], and select ANSI encoding to save.
After converting the encoding and running it again, the Chinese garbled problem is solved.
Declare the code page change in the original bat script file
chcp 65001
Run again, the Chinese garbled problem is solved.
Extensionchcp Command
Changes the active console code page.
Commonly used Code page mapping
Code page | Mapped character set |
---|---|
936 | GB2312 |
20127 | US-ASCII |
65001 | UTF-8 |
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if bat executes php Chinese garbled code. For more information, please follow other related articles on the PHP Chinese website!