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 ...
随机推荐
- 【python自动化测试】1- python基础和pycharm使用
python基础和pycharm使用 1.pycharm 1.1 为特定格式文件添加头信息 File--Settings--Editor--File and Code Templates--Pytho ...
- JZOJ 4270.【NOIP2015模拟10.27】魔道研究
魔道研究 题面 思路 简单的想,就是在 \(T\) 个可重集合每个中选出 \(k\) 个最大的数组成新的可重集合,其中 \(k\) 为其编号 然后在新的集合中选前 \(n\) 大的数,求其和 考虑开 ...
- 题解 P7623 [AHOI2021初中组] 收衣服
我还在小学的时候以现在初中名义我大五十牛逼参加了这次,然后身败名裂死磕这道题不会,现在觉得自己好傻啊 233333 显然这是要统计每个区间的贡献,所以我们可以打出来这个暴力,统计每个区间的次数,对于 ...
- Postgresql之闪回数据库示例
一.摘要 在Oracle中,若发生重大的误操作,那么我们可以使用flashback database命令来把数据库整体闪回到过去的误操作的时间点,当然前提是需要打开数据库的闪回功能. 在PG中,能否也 ...
- PostgresSql更改字段位置后,数据库异常
SQL server的studio有一个功能,可以随意拖拽表字段,更改其位置并使之重新排序,有同事问起,Postgres是否也可以.Postgres每个字段的顺序是在系统表pg_attribute里面 ...
- wordpress宕机原因及处理方法
2020年7月底,查看了网站日志,是wp-cron.php 导致异常. 原来这是WordPress定时任务,禁用即可. 在wp-config.php添加 /* 禁用定时任务 wp-cron */ de ...
- js - 解决微信环境下,ios软键盘收起后页面空白
思路:1.判断是否在微信中 2.判断是否在ios中 3.表单元素焦点将页面滚回到顶部 是否是微信环境 isWx() { let ua = navigator.u ...
- 【8】java之引用传递
一.引用传递 引用传递是整个 java 的精髓所在 引用传递核心意义:同一块堆内存空间可以被不同的栈内存所指向,不同栈内存可以对同一块堆内存内容进行修改. 范例:第一道引用传递范例 class Me ...
- vue3中对于/deep/和::v-deep的警告信息处理
目前发现两处警告信息: ::v-deep usage as a combinator has been deprecated. Use :deep() instead. the >>> ...
- Google Earth Engine——基于改进的RSEI评估生态环境(水体掩膜后)
未经允许,禁止随意转载,尊重他人版权,仅供学习参考,欢迎交流. 背景介绍 遥感生态指数(Remote Sensing Ecological Index)的获得,是使用主成分分析法耦合了绿度.湿度.干度 ...