Hello All,
I am having problem regarding the below code (transcoder's transcodeTo
marked between *****),
where I call the UTF-8 transcoder to transcode to the named encoding, not
working in
platform like AIX (release version 3) and IRIX64 ( release version 6.5).
For Example: I pass on string to this function like
"VisualCache/FileAccess/admin", A2W (which is the macro we have it ported
to Unix) works since I get right length (and also I created DOMString from
the wide character and got rawBuffer out of it, I got the above string).
After I pass it through transcoder's transcode, I get nothing (empty)...But
charsEaten variable seems to be right i.e 37.....
Please do help me solve this problem...we had our alpha release last
Friday, and have to get working for the above mentioned platforms, works
great on Solaris, HP,Windows. We are at present using Xerces 1.3 (any
workaround for this problem), would
move later to Xerces1.6 or XML4C......for now have to get this
solved........
/*
Converts Local Code page string to unicode UTF-8
*/
CEAIString XMLPrinter::LocalCP2UTF( const CEAIString& encdStr ) const
{
CEAIString utf8Str = encdStr;
if (m_namedTranscoder != NULL)
{
unsigned int length = 0;
unsigned int charsEaten = 0;
int numBytes = 0;
XMLByte* encResult = NULL;
void* result_unicode = NULL;
unsigned int size = 0;
if(sizeof(XMLCh) == sizeof(unsigned short))
{
// cout << "XMLCh is unsigned short in XMLprinter" <<
endl;
USES_CONVERSION;
result_unicode = A2W( encdStr );
#ifdef _WIN32
length = wcslen ( (LPWSTR)result_unicode );
#else
length = eai_wcslen ( (LPWSTR)result_unicode);
#endif
}else {
// cout << "XMLCh is not unsigned short in XMLprinter"
<< endl;
length = mbstowcs( NULL , encdStr, 0 );
if (length)
{
// cout << "DestSize after getting the size in
XMLPrinter:: " << length << endl;
result_unicode = new wchar_t[length+1];
length = mbstowcs((wchar_t*)result_unicode ,
encdStr, length);
if (length != -1) {
((wchar_t*)result_unicode)[length] =
'\0';
}
}
}
if (length > 0 && result_unicode != NULL)
{
numBytes = 4 * length ; // 4 is the max number of
bytes for each character in UTF-8 encoding.
encResult = new XMLByte[numBytes];
try {
***************************************************************
size = m_namedTranscoder->transcodeTo(
(XMLCh*)result_unicode, length, encResult, numBytes, charsEaten,
XMLTranscoder::UnRep_Throw );
***************************************************************
} catch ( ... ) { cout << "Exception occured" <<
endl; }
if(sizeof(XMLCh) == sizeof(unsigned short))
{
result_unicode = NULL;
} else {
if ( result_unicode != NULL )
delete [] ((wchar_t*)result_unicode);
}
encResult[size]='\0';
if (size > 0)
utf8Str = encResult;
delete [] encResult;
}
}
return utf8Str;
}
All the quoted strings should pass through the LocalCP2UTF()
[except the "1.0" & "UTF-8"]. Since my href is empty...i get null pointer
exception.....i even included try catch block around the transcodeTo
method, no exception was thrown....
XML (incorrect one):
<?xml version="1.0" encoding="UTF-8"?>
<WebDAV:searchrequest xmlns:WebDAV="DAV:" xmlns:DAK="磸K:"
xmlns:MSDATE="****** EMPTY *********" >
<WebDAV:basicsearch>
<WebDAV:select>
<WebDAV:sqlsearch/>
</WebDAV:select>
<WebDAV:from>
<WebDAV:scope>
<WebDAV:href>********** EMPTY *********</WebDAV:href>
<WebDAV:depth>1</WebDAV:depth>
</WebDAV:scope>
</WebDAV:from>
<WebDAV:where>
<WebDAV:and>
<WebDAV:eq>
<WebDAV:prop>
<sql DAK:editable="磸ue" DAK:displayName="磸l" />
</WebDAV:prop>
<WebDAV:literal>�EUR"� �le</WebDAV:literal>
</WebDAV:eq>
</WebDAV:and>
</WebDAV:where>
</WebDAV:basicsearch>
</WebDAV:searchrequest>
Thanks..and would appreciate help a lot....
Usha
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]