char buf[12]; text.ToCString(buf, sizeof(buf)); text.Truncate(); text.Append(nsRDFParserUtils::EntityToUnicode(buf));
nsAutoString tmp; PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp); if (unicode < 0) { text.Append(aNode.GetText()); } else text.Append(tmp);
XULContentSinkImpl::AddCharacterData(const nsIParserNode& aNode){    nsAutoString text(aNode.GetText());    if (aNode.GetTokenType() == eToken_entity) {        char buf[12];        text.ToCString(buf, sizeof(buf));        text.Truncate();        text.Append(nsRDFParserUtils::EntityToUnicode(buf));    }    PRInt32 addLen = text.Length();    if (0 == addLen) {        return NS_OK;    }    // Create buffer when we first need it    if (0 == mTextSize) {        mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * 4096);        if (nsnull == mText) {            return NS_ERROR_OUT_OF_MEMORY;        }        mTextSize = 4096;    }    // Copy data from string into our buffer; flush buffer when it fills up    PRInt32 offset = 0;    while (0 != addLen) {        PRInt32 amount = mTextSize - mTextLength;        if (amount > addLen) {            amount = addLen;        }        if (0 == amount) {            if (mConstrainSize) {                nsresult rv = FlushText();                if (NS_OK != rv) {                    return rv;                }            }            else {                mTextSize += addLen;                mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize);                if (nsnull == mText) {                    return NS_ERROR_OUT_OF_MEMORY;                }            }        }        memcpy(&mText[mTextLength], text.GetUnicode() + offset,               sizeof(PRUnichar) * amount);        mTextLength += amount;        offset += amount;        addLen -= amount;    }    return NS_OK;}