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文件中 ...
随机推荐
- 【数位dp】bzoj3131: [Sdoi2013]淘金
思路比较自然,但我要是考场上写估计会写挂:好像被什么不得了的细节苟住了?…… Description 小Z在玩一个叫做<淘金者>的游戏.游戏的世界是一个二维坐标.X轴.Y轴坐标范围均为1. ...
- Java使用ResourceBundle类读取properties文件中文乱码的解决方案
Java使用java.util.ResourceBundle类的方式来读取properties文件时不支持中文,要想支持中文必须将文件设置为ISO-8859-1编码格式,这对于开发工具默认为UTF-8 ...
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之enhanced coding styles
1.ANSI style 的代码比较紧凑. 下面规范推荐,比较好. 下面是带有parameter的module header的完整规范 一般1bit ,大家都是wire signal1 = gen_s ...
- python爬虫基础11-selenium大全5/8-动作链
Selenium笔记(5)动作链 本文集链接:https://www.jianshu.com/nb/25338984 简介 一般来说我们与页面的交互可以使用Webelement的方法来进行点击等操作. ...
- 用\r做出进度条
在做ftp作业的时候,需要做一个上传和下载的进度条,做的时候发现用\r很容易就能做出来 def show_progress(self, has, total): rate = float(has) / ...
- HDU 4348 To the moon 主席树
题意: 给出一个长度为\(n(n \leq 10^5)\)的序列,最开始时间\(t=0\),支持下面几个操作: \(C \, l \, r \, d\):将区间\([l,r]\)每个数都加上\(d\) ...
- windows下创建子进程过程中代码重复执行问题
windows在启动子进程的时候会将主进程文件倒入到子进程中.导入模块就相当于执行这个模块中的代码, 所以第一个print会在主进程中执行一次,又在被导入的过程中在子进程中又执行了一次. p.star ...
- Mac 之 STF 搭建(淘宝源安装)
参考链接:https://www.jianshu.com/p/5fe8cb7d214f (MAC直接安装STF)https://www.jianshu.com/p/c5c298486dbd(homeb ...
- hnust 不爱学习的小w
问题 C: 不爱学习的小W 时间限制: 2 Sec 内存限制: 64 MB提交: 1431 解决: 102[提交][状态][讨论版] 题目描述 “叮铃铃”上课了,同学们都及时到了教室坐到了座位上, ...
- TOJ4537: n阶行列式
4537: n阶行列式 Time Limit(Common/Java):1000MS/3000MS Memory Limit:65536KByteTotal Submit: 28 ...