首页 > 系统相关 >how to make the windows console work with utf-8 encoded project

how to make the windows console work with utf-8 encoded project

时间:2022-08-27 21:28:04浏览次数:74  
标签:code utf encoding windows make project editorconfig console

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

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;
}

start to run you code and check the result

标签:code,utf,encoding,windows,make,project,editorconfig,console
From: https://www.cnblogs.com/yusisc/p/16631501.html

相关文章

  • windows系统上的大文件拆分合并
    上周碰到一个并不算很大的问题,但是也有记录的价值。从公司带出来的离线补丁包需要传到客户服务器上,但是被告知并不能在现场机器上插U盘,会触发告警。上传只能把U盘上的......
  • 在Windows环境下安装虚拟机软件VirtualBox
    在Windows环境下安装虚拟机软件VirtualBoxVirtualBox是一款开源虚拟机软件。VirtualBox是由德国Innotek公司开发,由SunMicrosystems公司出品的软件,使用Qt编写,在Sun......
  • Windows OpenGL ES 图像亮度调节
    目录一.OpenGLES图像亮度调节1.原始图片2.效果演示二.OpenGLES图像亮度调节源码下载三.猜你喜欢零基础OpenGLES学习路线推荐:OpenGLES学习目录>>......
  • Java调用Windows系统命令CMD
    Java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令。cmd/cdir是执行完dir命令后关闭命令窗口。 cmd/kdir是执行完dir命令后不关闭命令窗口。 ......
  • Windows OpenGL 图像亮度调节
    目录一.OpenGL图像亮度调节1.原始图片2.效果演示二.OpenGL图像亮度调节源码下载三.猜你喜欢零基础OpenGLES学习路线推荐:OpenGLES学习目录>>OpenGL......
  • windows10下ZLMediaKit编译webrtc部分(亲测可用)
    windows下ZLMediaKit编译webrtc部分https://blog.csdn.net/whjy_lsq/article/details/122084828?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-......
  • Xmake v2.7.1 发布,更好的 C++ Modules 支持
    Xmake是一个基于Lua的轻量级跨平台构建工具。它非常的轻量,没有任何依赖,因为它内置了Lua运行时。它使用xmake.lua维护项目构建,相比makefile/CMakeLists.txt,配置语......
  • 寻找Windows下MySQL的错误日志
    MySQL版本:5.6Windows版本:Win764MySQL的错误日志记录了MySQL服务器启动、关闭和运行时出错等信息。默认名称为host_name.err,保存在MySQL实例指定的data目录下。但在MyS......
  • Windows c++获取磁盘剩余容量
    ULARGE_INTEGERfreeBytesAvailable;ULARGE_INTEGERtotalNumberOfBytes;//磁盘总字节ULARGE_INTEGERtotalNumberOfFreeBytes;//空闲字节GetDiskFreeSpa......
  • linux中常用的命令,三剑客awk,sed,grep在Windows系统中的使用
    1.首先是Windows版本的下载地址:https://sourceforge.net/projects/gnuwin32/files/,此地址截止发文都能使用该地址的工具版本都比较老,但是经过测试,基本能在Win10里面使用......