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文件中 ...
随机推荐
- Bootstrap 模态框 select2搜索框无法输入
去掉模态框的div中的 tabindex="-1" 这个属性 <div class="modal fade" role="dialog" ...
- MySQL 如何将Id相同的字段合并,并且以逗号隔开
数据库存的数据 sql: SELECT Id,GROUP_CONCAT(`Name` SEPARATOR ',') NAMES FROM `stu` GROUP BY Id;
- 图解一致性协议2PC和3PC
原图地址:https://www.processon.com/diagraming/5b89f6ace4b0d4d65bf10786
- Linux 安装Nginx+PHP+MySQL教程
一.安装nginx 通过yum安装openssl: yum -y install openssl openssl-devel 通过yum安装pcre: yum -y install pcre-deve ...
- Python 成长之路
Python roadmap python 基础 ... 内置常用函数.三元运算.递归 迭代器和生成器 模块和常用的模块 面向对象 对向对象进阶 网络编程 并发编程 ... 数据库 MySQL pym ...
- 用session模拟登陆,手动输入验证码
# 本练习是模拟登陆及验证码处理(把验证码下载到本地后手动输入) # 1 通过分析页面获得form表单的登陆接口为 action="https://www.douban.com/accoun ...
- R-codes-tips
1. 在shell执行R文件 chmod 0755 file.R Rscript file.R 2. 载入数据 data(dune) 3. attach() 将data.frame添加到R的搜索路径 ...
- percpu之静态变量
参考:Linux内核同步机制之(二):Per-CPU变量 CPU私有变量(per-CPU变量) 动态PCPU变量 setup_per_cpu_areas()初始化per-cpu数据. static v ...
- POJ - 2250 Compromise (LCS打印序列)
题意:给你两个单词序列,求出他们的最长公共子序列. 多组数据输入,单词序列长度<=100,单词长度<=30 因为所有组成LCS的单词都是通过 a[i] == b[j] 更新的. 打印序列的 ...
- huu 1251
#include <iostream> #include <cstdio> #include <cstring> #include <string> # ...