tinyxml2
tinyxml2 copied to clipboard
Read the special numeric character such   or 中 ,the result is wrong?
if ( *(p+1) == '#' ) {
const int buflen = 10;
char buf[buflen] = { 0 };
int len = 0;
char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
if ( adjusted == 0 ) {
*q = *p;
++p;
++q;
}
else {
TIXMLASSERT( 0 <= len && len <= buflen );
TIXMLASSERT( q + len <= adjusted );
p = adjusted;
memcpy( q, buf, len );
q += len;
}
}
hi @zpczzf
Start again.
Please provide testcase which shows that TinyXML-2 indeed failing. Or concept.
Until it have been proved by you, this issue have no sense.
Hi @leethomason I think you can close that issue as the StrPair::GetStr seems to work properly (as my unittests shows)
TEST(XmlStrPairTest, GetStrTest) {
{
char testString[] { " \0"};
tinyxml2::StrPair strPair;
strPair.Set(testString, testString+6, tinyxml2::StrPair::NEEDS_ENTITY_PROCESSING);
const char* result = strPair.GetStr();
EXPECT_EQ(testString[0], 0xc2);
EXPECT_EQ(testString[1], 0xA0);
EXPECT_EQ(testString[2], 0);
}
{
char testString[] { "中"};
tinyxml2::StrPair strPair;
strPair.Set(testString, testString+8, tinyxml2::StrPair::NEEDS_ENTITY_PROCESSING);
const char* result = strPair.GetStr();
EXPECT_EQ(testString[0], 0xe4);
EXPECT_EQ(testString[1], 0xb8);
EXPECT_EQ(testString[2], 0xad);
EXPECT_EQ(testString[3], 0);
}
}