原文地址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的更多相关文章

  1. 用xerces-c来进行xml schema校验

    在xerces-c的官方站点上有文章指引说明是怎样进行xml schema校验. http://xerces.apache.org/xerces-c/schema-3.html 给出的样例代码: // ...

  2. windows下使用xerces -c解析XML

    windows下使用Xerces-C++解析XML 前景提要 最近工作中遇到收到的数据为xml格式的情况,考虑到xml解析应该是个很常用的功能,应该有开源的lib库可以使用,于是就在网上找了找,果然发 ...

  3. 《理解 ES6》阅读整理:函数(Functions)(六)Purpose of Functions

    明确函数的双重作用(Clarifying the Dual Purpose of Functions) 在ES5及更早的ES版本中,函数调用时是否使用new会有不同的作用.当使用new时,函数内的th ...

  4. 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 ...

  5. General Purpose Hash Function Algorithms

    General Purpose Hash Function Algorithms post@: http://www.partow.net/programming/hashfunctions/inde ...

  6. libeXosip2(2) -- General purpose API.

    General purpose API. general purpose API in libeXosip2-4.0.0. More... Modules eXosip2 configuration ...

  7. 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 ...

  8. Purpose of ContextLoaderListener in Spring

    The ApplicationContext is where your Spring beans live. The purpose of the ContextLoaderListener is ...

  9. ffmpeg源码分析二:main函数和transcode函数 (转2)

    原帖地址:http://blog.csdn.net/austinblog/article/details/24804455 首先从main函数看起,关键解释部分已加注释,该函数在ffmpeg.c文件中 ...

随机推荐

  1. shopnc路由功能分析

    项目核心文件 core/shopld.php if (!@include(BASE_DATA_PATH.'/config/config.ini.php')) exit('config.ini.php ...

  2. 用宝塔软件在linux上自动安装php环境

    1.确保是纯净系统 确保是干净的操作系统,没有安装过其它环境带的Apache/Nginx/php/MySQL,否则安装不上 2.sudo进行安装 yum install -y wget &&a ...

  3. Lecture 3

    surface models 1. The two main methods of creating surface models are interpolation and triangulatio ...

  4. 如何在微信中发送"相册"文件时有选择性地显示视频文件

    相信很多微信用户在使用微信给朋友,同事发送相册中的文件时,微信会显示你手机中的视频文件,这样很不方便. 如果要完全不显示视频文件: 随便在手机中建立一个文件夹,名字叫 ".nomedia&q ...

  5. usb hub 设备流程图

    在此处负责而来:http://blog.csdn.net/xuelin273/article/details/38646851  下面的转载于:http://blog.csdn.net/qianguo ...

  6. 如何锁定Android系统CPU的频率

    接触到了Android系统的Performance测试,所以有锁定CPU的需求: 由于要首先读取到此系统所支持的CPU频率,之后再所支持的频率中选取你想要的频率,之后进行锁定. 这个过程,手动也是可以 ...

  7. HDU 3727 Jewel 主席树

    题意: 一开始有一个空序列,然后有下面四种操作: Insert x在序列尾部加入一个值为\(x\)的元素,而且保证序列中每个元素都互不相同. Query_1 s t k查询区间\([s,t]\)中第\ ...

  8. loj2275 「JXOI2017」颜色

    枚举右端点,然后看左端点合法情况. 先预处理每个颜色 \(i\) 的最大出现位置 \(max_i\) 和最小出现位置 \(min_i\).对于枚举右端点在一个位置 \(i\),凡是 \(max_k & ...

  9. Leetcode 477.汉明距离总和

    汉明距离总和 两个整数的 汉明距离 指的是这两个数字的二进制数对应位不同的数量. 计算一个数组中,任意两个数之间汉明距离的总和. 示例: 输入: 4, 14, 2 输出: 6 解释: 在二进制表示中, ...

  10. 递归函数的写法(以strcpy函数为例)

    1. 递归函数模板 递归的前提是,找到一个公共子问题(或公共操作),然后将该函数构造为递归函数. retType function( ... ) { 结束条件 { [处理] 返回 } 递归条件 { [ ...