gpt4 book ai didi

c++ - 使用repl.it将非ASCII字符输出到C++中的控制台

转载 作者:行者123 更新时间:2023-12-02 10:34:22 24 4
gpt4 key购买 nike

我正在使用repl.it编辑和编译一些C++代码。我想将obelus(分割符号)输出到控制台。下面的代码应该做到这一点。

char div_sign ='\366';
cout << div_sign << endl;

这在Visual Studio中有效,从我发现它应该适用于任何编译器。但是,我没有得到正确的输出。我唯一能想到的是repl不使用OEM字符集。有什么建议可以使它在repl中正常工作吗?

最佳答案

The only thing I can think of is the repl does not use the OEM character set



这是对的。
\366( 0xF6246)是OEM-US / CP437代码页中÷的字符代码。

repl.it将您写入 std::cout的内容视为UTF-8。相同字符的Unicode代码点是 \367( 0xF7247)。

将其编码为UTF-8可得到:
  std::cout << "\303\267";

这给出了repl.it的预期输出

关于c++ - 使用repl.it将非ASCII字符输出到C++中的控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60982314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com