在使用vs2015的时候突然发现使用cout输出中文乱码了,检查了控制台的编码方式是GBK,源代码是GB2312,按道理来说编码方式一致,不会出现输出中文乱码的情况,而且使用printf输出中文就能正确显示。具体例子如下:

#include <iostream>

using namespace std;

int main(int argc, char**argv)
{
	cout << "as机械先驱" << endl;
	cout << "机械先驱" << endl;
	cout << "ABCD" << endl;
	printf("机械先驱 \n");

	string str1("EFG");
	cout << str1 << endl;
	string str("我爱你");
	cout << str << endl;

	cin.get();
	return 0;
}

VS2015输出结果:

windows更新之后VS2015使用cout输出中文到控制台出现乱码

控制台编码方式:

windows更新之后VS2015使用cout输出中文到控制台出现乱码

源码编码方式:

windows更新之后VS2015使用cout输出中文到控制台出现乱码

windows更新之后VS2015使用cout输出中文到控制台出现乱码

在CSDN论坛发帖https://bbs.csdn.net/topics/392498171求助,得到了解决方法。是由于windows更新引起的,只需要将控制台设置成旧版本就能解决了。操作如下:选中控制台,点击右键,选择属性,按下图操作

windows更新之后VS2015使用cout输出中文到控制台出现乱码

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2021-08-24
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-04-27
  • 2021-06-22
  • 2022-01-02
  • 2021-10-21
  • 2022-01-29
  • 2022-12-23
相关资源
相似解决方案