Dev-Cpp icon indicating copy to clipboard operation
Dev-Cpp copied to clipboard

Problem resulted in printing chinese.

Open HsGalaxy opened this issue 4 years ago • 2 comments

This software is one of the most fanstastic IDE i've ever used. But,in C++,because of encoding method,i cannot output Chinese. such as

#include<iostream>
int main{std::cout<<“你好世界”;}

and wrong things are outputed.This is a little problem,also exits in many other IDEs.But in order to make devcpp perfect,i hope this can be fixed

HsGalaxy avatar Sep 19 '21 08:09 HsGalaxy

Is the last line here correct? image

pmcgee69 avatar Sep 22 '21 20:09 pmcgee69

I tried the fmt library : https://github.com/fmtlib/fmt

#include <iostream>
#include <windows.h>

#define FMT_HEADER_ONLY
#include "fmt\core.h"

int main() {
	SetConsoleOutputCP(936);
	
	std::cout << "aa  èéøÞǽлљΣæča \n - \n" << "bb  你好世界 \n - \n";
	
	fmt::print("123  ");   
	fmt::print("èéøÞǽлљΣæča \n\n");
	fmt::print("123  你好世界");

	getchar();
	return 0;
}

It works in the window the IDE creates. Or in a DOS console if you precede with "CHCP 936".

pmcgee69 avatar Sep 22 '21 20:09 pmcgee69