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 XMLCh
datatype.
'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文件中 ...
随机推荐
- day2-python 登录
# username = 'niuhanyang' # 写一个判断登录的程序: # 输入: username # password # 最大错误次数是3次,输入3次都没有登录成功,提示错误次数达到上限 ...
- nordic芯片开发——烧写方法记录
在开发nordic芯片的时候,分为存外设开发和结合softdevice开发,另外还有结合mbr的开发(这个暂时没有深究)在裸机开发的时候,sdk里面称为blank,把芯片的程序erase之后,直接下载 ...
- 记一次虚拟机无法挂载volume的怪异问题排查
故障现象 使用nova volume-attach <server> <volume>命令挂载卷,命令没有返回错误,但是查看虚拟机状态,卷并没有挂载上. 故障原因 疑似虚拟机长 ...
- 金阳光Android自动化测试第一季
第一季:http://www.chuanke.com/v1983382-106000-218422.html 第一节:Android自动化预备课程基础(上) 1. 基于坐标点触屏:monkey ...
- jubeeeeeat(网络流)
jubeeeeeat 总时间限制: 1000ms 内存限制: 256000kB 描述 众所周知,LZF很喜欢打一个叫Jubeat的游戏.这是个音乐游戏,游戏界面是4×4的方阵,会根据音乐节奏要求玩 ...
- tarjan - SPFA - Luogu 3387【模板】缩点
[模板]缩点 题目描述 给定一个n个点m条边有向图,每个点有一个权值,求一条路径,使路径经过的点权值之和最大.你只需要求出这个权值和. 允许多次经过一条边或者一个点,但是,重复经过的点,权值只计算一次 ...
- WebApp开发入门
web app 的技术平台很多,如adobe phonegap.sencha touch.appcan(国产).dcloud(国产)平台.我选择了dcloud平台,原因:简单,容易上手. web ap ...
- Leetcode25--->Reverse Nodes in k-Group(以k个节点为段,反转单链表)
题目: 给定一个单链表,一次反转k个节点,最终返回翻转后的链表的头节点:如果链表不足k个,则不变 举例: Given this linked list: 1->2->3->4-> ...
- 九度oj 1005
题目1005:Graduate Admission 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6182 解决:1791 题目描述: It ...
- 修改mysql数据的字符集校验规则使其区分大小写
mysql 使用utf8字符集默认的校验规则collate为utf8_general_ci,不区分数据的大小写 测试如下 ::) character set utf8 collate utf8_bin ...