xmlEscapeEntities : char out of range

Hi experts,

I am using libxml2 to generate an XML document containing details read from a database.  The document is correctly created, but I am seeing the above warning message.  Could someone tell me why this is generated.  Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Did you verify whether the text read from the database contains control characters ? XML only accepts characters over 0x20, and 0x09, 0x0A and 0x0D. So, these are invalid :

        0x00 -> 0x08
        0x0B -> 0x0C
        0x0E -> 0x1F

If your string contains any of these, this error is thrown.

It could also occur in UTF-8 strings. But I assume that's not the case since you're using char*.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ambuliAuthor Commented:
Thank you?
Does a NULL from database would cause this?
>> Does a NULL from database would cause this?

By NULL do you mean a NULL character ? If so, then that will just be a premature ending of the string.

If you mean NULL as in a NULL pointer :

        char *name = NULL;

then I think that would crash your application (ie. you need to check for NULL).
>> By NULL do you mean a NULL character ? If so, then that will just be a premature ending of the string.

Correction : it depends on how you obtained the length of the string. If you used strlen, then my answer is valid : it will be a premature end if the string.

If however you obtained the length from the database somehow, and there is a NULL character in the middle of the string, then this will indeed cause that error.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.