Xerces XMLString :: transcode null/empty答复 [英] Xerces XMLString::transcode null/empty reply
本文介绍了Xerces XMLString :: transcode null/empty答复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Xerces转码返回一个空字符串.我认为这与语言环境问题有关,但我遇到了麻烦.
Xerces transcode is returning an empty string. I think it is related to locale issues, but i'm stuck.
我有一个简单的程序:
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <string>
#include <stdio.h>
XERCES_CPP_NAMESPACE_USE
using namespace std;
int main(int argc, char* argv[])
{
string a = "Não";
try
{
XMLPlatformUtils::Initialize("pt_PT");
} catch(const XMLException& e)
{
fprintf(stdout,"ERROR INITIALIZING\n");
}
XMLCh *auxCh3 = XMLString::transcode(a.c_str());
fprintf(stdout,"### %s ###\n",XMLString::transcode(auxCh3));
XMLString::release(&auxCh3);
XMLPlatformUtils::Terminate();
return 0;
}
结果是:
"### ###"
如果我删除了ã,结果就可以了:
If i remove the ã, the result is ok:
"###否###"
服务器的语言环境定义为:
The server's locale is defined to:
[]$ locale
LANG=pt_PT
LC_CTYPE="pt_PT"
LC_NUMERIC="pt_PT"
其中之一是可用的:
[]$ locale -a|grep pt_PT
pt_PT
感谢您的帮助.
推荐答案
程序启动时,默认情况下处于"C"语言环境.这是由POSIX标准定义的.您需要调用setlocale(LC_ALL,"")
(不要忘记#include <locale.h>
),以根据系统环境变量设置语言环境.
When your program starts, by default it is in "C" locale. This is defined by POSIX standard. You need to call setlocale(LC_ALL,"")
(don't forget to #include <locale.h>
) , to set the locale according to system environment variables.
这篇关于Xerces XMLString :: transcode null/empty答复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文