如何将国际字符发送到Windows控制台? [英] how to send international characters to windows console?

查看:52
本文介绍了如何将国际字符发送到Windows控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:

#include <windows.h>

int main() {
  SetConsoleOutputCP(CP_UTF8);
  system("echo Ιλιάδα");
}

控制台上的打印:来源使用带有BOM的UTF-8编码.

prints on console: Ιλιάδα Source is encoded in UTF-8 with BOM.

但是,如果我尝试: system(L"echoΙλιάδα"); ,则会收到错误: error:无法将参数'的'const wchar_t *'转换为'const char *'1"到"int system(const char *)" .当然,我在这里什么都没想到.还有其他可以接受这些字符的功能吗?

But if I try: system(L"echo Ιλιάδα");, I get error: error: cannot convert 'const wchar_t*' to 'const char*' for argument '1' to 'int system(const char*)'. And of course I didn't expect anything else here. Is there any other function that will accept these characters ?

推荐答案

对宽字符串使用 _wsystem 一个.

这篇关于如何将国际字符发送到Windows控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆