----- Original Message -----
Sent: Thursday, June 08, 2000 1:02
PM
Subject: Believed bug in
XMLString::trim(...)
Hi,
I got some problems porting some
code from java to c++ making use of the trim function so I tested the
following simple code:
// code starts here:
#include <iostream>
#include <util/PlatformUtils.hpp>
#include <util/XMLString.hpp>
int main() {
// Init the XML platform
try {
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch) {
cout << "Error during platform init! Message:\n"
<< endl;
return 1;
}
char *help = " simple test ";
char *help1;
cerr << "ORIGINAL STRING: ." << help << "." << XMLString::stringLen(help) << endl;
XMLCh *ptr = XMLString::transcode(help);
help1 = XMLString::transcode(ptr);
cerr << "XMLCh string : ." << help1 << "." << XMLString::stringLen(help1) << endl;;
delete help1;
XMLString::trim(ptr);
help1 = XMLString::transcode(ptr);
cerr << "Trimmed XMLCh : ." << help1 << "." << XMLString::stringLen(help1) << endl;
delete help1;
help1 = XMLString::replicate(help);
XMLString::trim(help1);
cerr << "Trim. original : ." << help1 << "." << XMLString::stringLen(help1) << endl;
delete help1;
return 0;
}// code ends here
what I get is the following output:
ORIGINAL STRING: . simple test .17
XMLCh string : . simple test .17
Trimmed XMLCh : . simple test .17
Trim. original : .simple testest.14
What I believe is wrong (in both cases of the trim function).
According
to the api doc of these functions, trim should "trim" any extra character at
the end of the string (I believe extra character means as in the java
String.trim() method whitespaces, newline and tab).
Is this a bug or did I missunderstand the meaning of trim, and if so, why
is there a difference between the XMLCh* version and the char* version ?
The system I am running it is SuSE Linux 6.1 (kernel 2.2.7) and the
compiler is gcc 2.95.2
Greetings
Michele
--
-------------------------------------------------
Michele Laghi
Av. Benavides 163 dpto. 301
MIRAFLORES-LIMA (PERU)
tel. +51 1 4463956
e-mail: [EMAIL PROTECTED]
-------------------------------------------------