1.windows 环境下,VS Code编译器默认字符集为UTF-8,但是本地测试发现,中文入参传到后端接口仍乱码
2.点击运行和调试,打开launch.json配置文件,默认没有配置项encoding,需要手动添加
launch.json
3.重启项目再次访问接口,乱码解决了
补充:如果VS Code控制台乱码,需要在settings.json配置中添加如下配置即可解决
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoLogo",
"-NoExit",
"-Command",
"chcp.com 65001"
]
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/K",
"chcp 65001"
],
"icon": "terminal-cmd"
}
}