当前位置:网站首页>Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
2022-07-02 11:17:00 【System_ sleep】
Preface
stay VS2019 in , If the code contains Chinese string definitions or comments , It will lead to all kinds of inexplicable compilation errors , Even if you are lucky , There is no error in compilation , You will also encounter the problem of printing Chinese garbled codes on the console , It makes people feel irritable .
Compilation problems
1. Chinese string constants are defined in the code, resulting in compilation errors :“ Line breaks in constants “ ;
2. The code contains Chinese comments, which leads to compilation errors : Can't find XXX ( macro 、 Variable )、XXX Is not a constant / Variables and other problems caused by missing declarations ;
The problem of printing garbled code
Code print Chinese string , The output at the command prompt is garbled ;
resolvent , Choose one of the three methods :
One . Modify the code file format to utf-8 Signed , Give Way MSVC The compiler can automatically recognize and utf-8 BOM Format load file :
- Use an external editor to save the code file as utf8-BOM Format ;
- or Open the code file , stay VS2019 “ Advanced save options ” Select the code file saving format as “Unicode- Signed “;
Two . Change the code format :
Modify Chinese string 、 Format of Chinese Notes , Add English space at the end of Chinese , Give Way MSVC The compiler can use GBK Code loading and compiling Chinese utf-8 Encoded string , It can solve the problem of compilation errors , Print or garbled ;
3、 ... and . Force the designation of MSVC The encoding format of the code file loaded by the compiler :
- stay VS2019“ project ”-“ Engineering properties ” Dialog box -“C/C++”-“ All options " Subpage , stay “ Additional options ” Add in “/utf-8” ( Equate to ”/source-charset:utf-8 /execution-charset:utf-8");
- stay VS2019“ project ”-“ Engineering properties ” Dialog box -“C/C++”-" All options " Subpage , stay “ Additional options ” Add in “/source-charset:utf-8 /execution-charset:gbk” ( The former represents the encoding of the file itself , The latter indicates the encoding of bytes in the compiled character array );
summary :
1. If it's a new project , Recommended method 1 , Let all new code files be unified as utf-8 BOM Format ;
2. If it is cross platform code , And the document contains a small amount of Chinese Notes , You can try method 2 ;
3. If it is an existing historical complex project ( Solutions that are not exported using tools ), You can try method 3 , But you need to pay attention to the settings execution-charset when , Consider at the same time UI Requirements for string encoding of both display and print ( It may not be the same );
reference information :
边栏推荐
- [play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]
- TIPC 寻址2
- 数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
- sql left join 主表限制条件写在on后面和写在where后面的区别
- 三.芯片啟動和時鐘系統
- Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)
- From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
- [quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
- 二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
- Supermarket (heap overload
猜你喜欢

Solve the problem of data blank in the quick sliding page of the uniapp list

Why does LabVIEW lose precision in floating point numbers

QT学习日记8——资源文件添加

数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
![[AGC] build service 3 - authentication service example](/img/89/63f367270e806e89c4ff92360dc3c5.png)
[AGC] build service 3 - authentication service example

Verilog 和VHDL有符号数和无符号数相关运算

Importerror: impossible d'importer le nom « graph» de « graphviz»

TIPC Cluster5

三.芯片啟動和時鐘系統

二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
随机推荐
Flick two open, realized a batch lookup join (with source code)
[ark UI] implementation of the startup page of harmonios ETS
在网上开股票账户安全吗?我是新手,还请指导
Order by注入
webauthn——官方开发文档
Special topic of binary tree -- acwing 1589 Building binary search tree
【深入浅出玩转FPGA学习3-----基本语法】
Regular and common formulas
Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
启牛商学院给的股票账户安全吗?能开户吗?
Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)
【深入浅出玩转FPGA学习4----漫谈状态机设计】
Jenkins安装
【深入浅出玩转FPGA学习2----设计技巧(基本语法)】
Jinshanyun - 2023 Summer Internship
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
V2x SIM dataset (Shanghai Jiaotong University & New York University)
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
enumrate的start属性的坑

