如何使用C ++和xml以及UTF-8显示井号 [英] How to display pound symbol using C++ and xml and UTF-8

查看:131
本文介绍了如何使用C ++和xml以及UTF-8显示井号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要显示一个英镑符号,&虚拟键盘的按钮文本上的符号。当我按下它们时,它们应该显示相应的文字英镑符号和&符号。



我有一个字符串表(xml文件) ,我正在尝试显示按钮文本磅(英镑)符号)和另一个按钮我想使用utf-8和C ++和xml显示&(&符号)符号。

我输入的xml字符串表格如下:

< element id =buttonText>&



它给出错误(非法语法,期待有效的起始名称字符)



请让我知道如何使用按钮文本& (&符号)和磅(英镑符号)

当我按下那些按钮时,应显示相应的文字

(英镑符号,&)



感谢您的帮助。



谢谢,

Sudhkar

解决方案

您可以使用字符实体表示XML中的任何字符,甚至是为XML语法保留的字符(例如&#x00A3; ):

http://dev.w3.org/ html5 / html-author / charref [ ^ ],

http://www.w3。 org / TR / 2014 / REC-xml-entity-names-20140410 [ ^ ]。



另请参阅: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references [ ^ ]。



(请注意,在XML中,您不能使用命名为HTML定义的实体(如& pound; )但在XML中未定义。您需要定义它们或使用数字字符引用



-SA

Hi All,

I need to display a pound symbol, and & symbol on button texts of a virtual keyboard.when I press them they should display the corresponding text pound symbol and ampersand symbol .

I have a string table(xml file) , for which the button text i am trying to display Pound (sterling) symbol) and for another button i want to display &(ampersand) symbol using utf-8 and C++ and xml.
In the xml string table when I type as follows
<element id="buttonText">&

it is giving the error (illegal syntax ,expecting a valid start name character)

Please let me know how i can use the button text & (ampersand) and pound(sterling symbol)
and when i press those buttons then the corresponding text should be displayed
(pound symbol , &)

Appreciate your help.

Thanks,
Sudhkar

解决方案

You can represent any character in XML, even the one reserved for XML syntax, using character entity (such as &#x00A3;):
http://dev.w3.org/html5/html-author/charref[^],
http://www.w3.org/TR/2014/REC-xml-entity-names-20140410[^].

See also: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references[^].

(Note that in XML you cannot use named those entities defined for HTML (like &pound;) but undefined in XML. You either need to define them or use a numeric character reference instead.)

—SA


这篇关于如何使用C ++和xml以及UTF-8显示井号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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