how to make the windows console works with utf-8 encoded project
the console of the windows os
is not working in the utf-8
encoding, by default. When you force your code be encoded with utf-8
, the console will not print what you want.
Here is how to configure your project encoding with utf-8
, and work as it is in windows.
configure visual sutdio
to encoding with utf-8
add a .editorconfig
file to you project. visual studio
will use the encoding as the configuration file asked.
put the code in the .editorconfig
# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\data\playGround\playGround_y9kp\playGround_y9kp\ codebase based on best match to current usage at 2022/8/27
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
# [*.cs]
[*.{js,py,cpp, hpp, c, h}]
charset = utf-8
set your project build and execute in utf-8
this will be configured in the project property
page.
tell the working encoding at the very beginning of you code
method 0
int main(int argc, char** argv)
{
system("chcp 65001"); // set the console work with utf-8 encoding.
cout << "aaaaaaaaaa" << endl;
cout << "噫吁戏危乎高哉" << endl;
cout << "aaaaaaaaaa" << endl;
return 0;
}
method 1
use the gragma
#pragma execution_character_set("utf-8")
int main(int argc, char** argv)
{
cout << "aaaaaaaaaa" << endl;
cout << "噫吁戏危乎高哉" << endl;
cout << "aaaaaaaaaa" << endl;
return 0;
}
start to run you code and check the result
reference
c++ - Is there an easy way to write UTF-8 octets in Visual Studio? - Stack Overflow
https://stackoverflow.com/questions/19987448/is-there-an-easy-way-to-write-utf-8-octets-in-visual-studio
(118条消息) #pragma execution_character_set解决中文乱码_lyingcloud的博客-CSDN博客_execution_character_set
https://blog.csdn.net/chenhongwei610/article/details/101512960
execution_character_set pragma | Microsoft Docs
https://docs.microsoft.com/en-us/cpp/preprocessor/execution-character-set?view=msvc-170
/utf-8 (Set source and execution character sets to UTF-8) | Microsoft Docs
https://docs.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
how to make the windows console works with utf-8 encoded project的更多相关文章
- windows console Kill PID 端口查看
开始--运行--cmd 进入命令提示符 输入netstat -ano 即可看到所有连接的PID 之后在任务管理器中找到这个PID所对应的程序如果任务管理器中没有PID这一项,可以在任务管理器中选&qu ...
- [分享] Code::Blocks Windows Console 中文亂碼解決
相信各位大大們應該都有聽過Code::Blocks這個IDE,但網路上有許多人反應Code::Blocks不能編出中文的Console程式,但 Code::Blocks最新的版本預設使用UTF-8做為 ...
- 在C#中,Windows Console控制台 设置控制台标题、禁用关闭按钮、关闭快速编辑模式、插入模式
设置控制台标题 禁用关闭按钮 关闭快速编辑模式 关闭插入模式 设置控制台标题.禁用关闭按钮 #region 设置控制台标题 禁用关闭按钮 [DllImport("user32.dll&quo ...
- windows console 控制台自启动
var fileName = Assembly.GetExecutingAssembly().Location; System.Diagnostics.Process.Start(fileName);
- Git for Windows v2.11.0 Release Notes
homepage faq contribute bugs questions Git for Windows v2.11.0 Release Notes Latest update: December ...
- Scott Hanselman's 2014 Ultimate Developer and Power Users Tool List for Windows -摘自网络
Everyone collects utilities, and most folks have a list of a few that they feel are indispensable. ...
- Professional C# 6 and .NET Core 1.0 - Chapter 39 Windows Services
本文内容为转载,供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处:Professional C# 6 and .NET Core 1.0 - Chapter 39 Windows Servi ...
- 环境搭建文档——Windows下的Git搭建详解
Git是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理.具体安装步骤如下: 第一步:先从官网下载最新版本的Git 官网地址:https://git-scm.com/do ...
- 在 windows 上安装 git 2.22
下载 by win 下载地址:https://git-scm.com/download/win 如下图.选择对应的版本下载: 安装 by win 1.双击下载好的git安装包.弹出提示框.如下图: 2 ...
- 在 windows 上安装 git 2.15
下载 by win 下载地址:https://git-scm.com/download/win 如下图.选择对应的版本下载: 安装 by win 1.双击下载好的git安装包.弹出提示框.如下图: 2 ...
随机推荐
- JavaScript 中的 apply、call、bind
在 JavaScript 中,apply.call.bind 是三个与函数调用相关的方法,它们都允许你在调用函数时手动设置函数的上下文(即 this 指向). 1.apply 方法:apply 方法允 ...
- 云小课|MRS数据分析-通过Spark Streaming作业消费Kafka数据
阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要:Spark Str ...
- HTML5----响应式(自适应)网页设计(自动适应屏幕大小)
HTML5----响应式(自适应)网页设计(自动适应屏幕大小) 现在,很多项目都需要做响应式或者自适应的来适应我们不同屏幕尺寸的手机,电脑等设备,那么就需要我们在页面上下功夫,但移动端的布局不同于pc ...
- 9.【go-kit教程】go-kit集成Prometheus
在 Go kit 中集成 Prometheus 进行 API 监控可以帮助开发人员更好地了解系统的性能和行为,提高系统的可观察性和可靠性.下面是一个简单的示例,演示如何在 Go kit 中集成 Pro ...
- nodejs 接收参数,js前端传参方法
nodejs // 接口:查询检测结果 req.query接收 router.get('/getDetectionResult', (req, res) => { console.log(req ...
- PostGIS之Geometry
1. 概述 PostGIS 是PostgreSQL数据库一个空间数据库扩展,它添加了对地理对象的支持,允许在 SQL 中运行空间查询 PostGIS官网:About PostGIS | PostGIS ...
- 如何设置VBA代码的密码?如何取消VBA代码的密码?
经常有网友问,用Access把软件开发好了,怎么样设置VBA代码的密码?以保护自己的代码不被同事修改.这里简单整理了一下.设置VBA代码的密码及取消VBA代码的密码步骤如下:1.打开任意一个窗体,进入 ...
- 简单使用wireshark
wireshark抓包工具 拓扑图: 拓扑图解释:终端用户使用wireshark抓包工具监听无线网卡,监听时,终端访问互联网,可实时监听网络抓包 操作步骤: 一,打开wireshark抓包工具,监听网 ...
- vs2019中添加rdlc的报表设计器
在Visual studio 2019中,不会默认安装rdlc的报表设计器,所以需要自行添加. 1. 打开VS2019, 找到扩展-->管理扩展 2. 在扩展管理中,点击"联机&quo ...
- vue学习 第一天 html 基础
1.web标准的构成: <结构Structure>(对应html文件).<表现Presentation>(对应css文件) 和<行为Behavior>(对应js)三 ...