Purpose of XMLString::transcode
原文地址http://stackoverflow.com/questions/9826518/purpose-of-xmlstringtranscode
I don't seem to understand the purpose of XMLString::transcode(XMLCh*) andXMLString::transcode(char*) , because obviously I don't understand the difference betweenXMLCh* and char*. Can someone please make things clearer for me ?
Xerces encodes information as UTF-16 internally. The UTF-16 data is stored using the XMLChdatatype.
'C-style' strings use char which is in the local code page (probably UTF-8, but it depends on the platform and settings) You use transcode to convert between the two.
For instance if you want to feed some data from Xerces to another library and that library expects text in the local code page, you need to transcode it. Also, if you have char data and want to feed it to Xerces, you need to transcode it to XMLCh, because that is what Xerces understands.
For example:
// to local code pageDOMNode*node =...;char* temp =XMLString::transcode(node->getNodeValue());
std::string value(temp);XMLString::release(&temp);// from local code pageDOMElement*element =...;XMLCh*tag =XMLString::transcode("test");DOMNodeList*list= element->getElementsByTagName(tag);XMLString::release(&tag);
Do not forget to release the string! Better is to write some wrapper round it but there are examplesavailable on the internet (just search for a class named XercesString).
Purpose of XMLString::transcode的更多相关文章
- 用xerces-c来进行xml schema校验
在xerces-c的官方站点上有文章指引说明是怎样进行xml schema校验. http://xerces.apache.org/xerces-c/schema-3.html 给出的样例代码: // ...
- windows下使用xerces -c解析XML
windows下使用Xerces-C++解析XML 前景提要 最近工作中遇到收到的数据为xml格式的情况,考虑到xml解析应该是个很常用的功能,应该有开源的lib库可以使用,于是就在网上找了找,果然发 ...
- 《理解 ES6》阅读整理:函数(Functions)(六)Purpose of Functions
明确函数的双重作用(Clarifying the Dual Purpose of Functions) 在ES5及更早的ES版本中,函数调用时是否使用new会有不同的作用.当使用new时,函数内的th ...
- Reading With Purpose: A grand experiment
Reading With Purpose: A grand experiment This is the preface to a set of notes I'm writing for a sem ...
- General Purpose Hash Function Algorithms
General Purpose Hash Function Algorithms post@: http://www.partow.net/programming/hashfunctions/inde ...
- libeXosip2(2) -- General purpose API.
General purpose API. general purpose API in libeXosip2-4.0.0. More... Modules eXosip2 configuration ...
- However, a general purpose protocol or its implementation sometimes does not scale very well.
https://netty.io/wiki/user-guide-for-4.x.html The Problem Nowadays we use general purpose applicatio ...
- Purpose of ContextLoaderListener in Spring
The ApplicationContext is where your Spring beans live. The purpose of the ContextLoaderListener is ...
- ffmpeg源码分析二:main函数和transcode函数 (转2)
原帖地址:http://blog.csdn.net/austinblog/article/details/24804455 首先从main函数看起,关键解释部分已加注释,该函数在ffmpeg.c文件中 ...
随机推荐
- pandas删除及其映射修改操作。
1.使用drop_duplicates()函数删除重复的行 df.drop_duplicates() 2.映射 映射的含义,创建一个映射关系,把values元素和一个特定的标签或字符串绑定 map = ...
- 【android】android对位图文件的支持
Android 支持以下三种格式的位图文件:.png(首选)..jpg(可接受)..gif(不建议).
- (转)iOS平台UDID方案比较
苹果在iOS6中禁用了[UIDevice uniqueIdentifier],在iOS7中又把mac地址的获取给堵上了.没办法,毕竟人家是老大,说不让你用,你也没办法. 在这边总结一下现有的一部分 ...
- i2c_drivers个人分析
\arch\arm\mach-mx6\board-mx6q_sabresd.c static struct i2c_board_info i2c_board_info_rtc[] __initdata ...
- CentOS 7.0 使用 yum 安装 MariaDB 及 简单配置
1.安装MariaDB 安装命令 yum -y install MariaDB-server MariaDB-client 安装完成MariaDB,首先启动MariaDB 设置开机启动 接下来进行Ma ...
- bs4--官文--搜索文档树
搜索文档树 Beautiful Soup定义了很多搜索方法,这里着重介绍2个: find() 和 find_all() .其它方法的参数和用法类似,请读者举一反三. 再以“爱丽丝”文档作为例子: ht ...
- 异常 ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang.test.MyView
发现自定义view时出现ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang. ...
- jmeter返回的Unicode转换成utf8
该问题通过查找资料借鉴前辈门的经验得到了解决,记录下来是为了后面能够用到 最近发现有些接口返回的时unicode类型的,如下图所示: 因此只需要在jmeter中添加后置处理器:BeanShell Po ...
- 《Python全栈开发指南》第3版 Alex著(LFXC2018)
第一章 Python基础——Python介绍&循环语句 1.1 编程语言介绍 1.2 Python介绍 1.3 Python安装 1.4 第一个Python程序 1.5 变量 1.6 程序交互 ...
- [python测试框架学习篇] 分享一个和adb相关的测试框架
https://testerhome.com/topics/7106 (user: zteandallwinner password: same to qq ) 264768502 · # ...