开发者

Why aren't my hyphens displaying correctly using std::cout?

开发者 https://www.devze.com 2023-02-12 08:16 出处:网络
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).

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?


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".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号