简体   繁体   English

C ++特殊字符显示为“?”

[英]C++ special characters displays as “?”

I want to print a box using special characters like this 我想使用这样的特殊字符来打印框

      cout << "╔═══╗" << endl;
      cout << "║   ║" << endl;
      cout << "║   ║" << endl;
      cout << "╚═══╝" << endl;

but it displays like this 但它显示像这样

      ?????
      ?   ?
      ?   ?
      ?????

How can I fix this? 我怎样才能解决这个问题?

You could try this one: 您可以尝试以下方法:

cout << (char)201 << (char)205 << (char)187 << endl;
cout << (char)186 << " "       << (char)186 << endl;
cout << (char)186 << " "       << (char)186 << endl;
cout << (char)200 << (char)205 << (char)188 << endl;

I tested it and prints what you want 我测试了它并打印出你想要的

Find out what character set the terminal you are viewing the program output on is using, then use escape codes to put those characters in your strings 找出正在查看程序输出的终端所使用的字符集,然后使用转义码将这些字符放入字符串中

There are several types and editor you are programming with may be using a different kind the program displays with. 您正在编程的几种类型和编辑器可能使用了与程序一起显示的另一种类型。

https://en.wikipedia.org/wiki/Box-drawing_character https://zh.wikipedia.org/wiki/Box-drawing_character

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM