为什么我的连字符无法使用 std::cout 正确显示?
我正在尝试使用 std::cout 打印出以下字符串:
“Encryptor –pid1 0x34f –pid2”
'-' 字符显示为 u,上面有一个抑扬符(我不知道如何输入)。
如何按预期打印连字符?
I am trying to print out the following string using std::cout :
"Encryptor –pid1 0x34f –pid2"
the '-' characters appear as u's with a circumflex above them (I'm not sure how to type this).
How do I print out the hyphen as intended?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那不是连字符。
这是一个“n-dash”,它将根据编码设置在不同的控制台上呈现不同的效果。
在西方布局中,连字符键通常位于键盘的数字行上。
That was not a hyphen.
It was a "n-dash", which will render differently across consoles based on encoding settings.
The hyphen key is usually on the number row of your keyboard, on Western layouts.
确保您的终端的字符编码理念与源代码的理念相匹配。当然,如何做到这一点取决于您的操作系统、您正在使用的终端模拟器(假设它根本就是模拟器)等等,您都没有说明。
另外,在您的示例中,这不是连字符,它太长了。这可能是一个“破折号”。
Make sure your terminal's idea of the character encoding matches that of your source code. How to do this, of course, depends on your operating system, which terminal emulator (assuming it's an emulator at all) you're using, and so on, neither of which you state.
Also, that's not a hyphen in your example, it's too long. It's probably an "em dash".