插入“£”在C ++中登录输出字符串 [英] Inserting a "£" sign in an output string in C++

查看:218
本文介绍了插入“£”在C ++中登录输出字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

cout << "String that includes a £ sign";

然而,编译器不能识别£符号,而是显示重音u 。我可以使用以下方法插入一个:

However, the £ sign is not being recognised by the compiler, and instead an accented u is being displayed. I'm able to insert one using the following method:

cout << "String that includes a " << char(156) << " sign";

其中156是£符号的ASCII码。有没有办法我可以包括这个ASCII代码在字符串本身,而不必像这样分开?例如:

where 156 is the ASCII code of the £ sign. Is there a way I can include this ASCII code in the string itself without having to separate it out like this? For example:

cout << "String that includes a <some way of iserting the £ sign> sign";


推荐答案

£没有ASCII代码 - ASCII是7位(0..127)。有各种扩展的8位字符集,其中包括£,但没有单个标准,并且£符号在不同的环境中具有各种不同的值。如果您需要具有最大可移植性的国际符号,则应该使用Unicode。

£ does not have an "ASCII code" - ASCII is 7 bits (0..127). There are various extended 8 bit characters sets which include £ but there is no single standard for this and the £ symbol may have various different values in different environments. You should probably be using Unicode if you need international symbols with maximum portability.

这篇关于插入“£”在C ++中登录输出字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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