You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by exits funnel <ex...@yahoo.com> on 2005/03/14 03:40:15 UTC

is chars argument in characters( ) call null terminated?

Hello,

I'm wondering if I can count on the fact that the
chars argument to the characters( ) method will be a
null terminated array?  The documentation seems not to
indicate either way, but the fact that the length is
passed explicitly suggests that it is not neccasarily
null temrinated.  Still, in the tests I've run,
chars[length] has alwasy been zero.

The reason I ask is because I'd like to call
XMLString::transcode so I can place the contents into
an std::string.  Though again the documentation is
quiet on the issue I assume that transcode required
the passed XMLChar array to be null terminated, is
that right?  If it is and if the char argument is not
guaranteed to be null terminated than I guess I'll
have to make a copy before calling transcode.  If
anyone could clear this up for me that would be great.

-exits


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: is chars argument in characters( ) call null terminated?

Posted by da...@us.ibm.com.
> I'm wondering if I can count on the fact that the
> chars argument to the characters( ) method will be a
> null terminated array?

No, you cannot.

> The documentation seems not to indicate either way,
> but the fact that the length is passed explicitly
> suggests that it is not neccasarily null temrinated.
> Still, in the tests I've run, chars[length] has
> alwasy been zero

That's just an artifact of the current implementation, or the documents 
you are parsing.

> The reason I ask is because I'd like to call
> XMLString::transcode so I can place the contents into
> an std::string.

Make sure you transcode to UTF-8.

> If it is and if the char argument is not
> guaranteed to be null terminated than I guess I'll
> have to make a copy before calling transcode.

Why?  The transcoder interface does not require this.  Do not use 
XMLString::transcode(), whatever you do, because it transcodes to the 
local code page, and you have no guarantee that all characters can be 
represented.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org