Non Null Terminated string

R

Raghavendra Mahuli

Hi,
Is there anything called Non Null Terminated string (may be in UTF or
something) i.e. a string which does not have a '\0' at the end to
terminate.
In that case how can the end be identified?





Thanks in advance

regards,

Raghu
 
Y

Yandos

Raghavendra Mahuli napsal(a):
In that case how can the end be identified?

You will have to know exact length of the string if you don't want to
use null terminated string. In such case the information about length is
usually placed before the string (first four bytes).

Y.
 
R

Raghavendra Mahuli

Hi Yandos,

Ok, Thanks ..
But is it used a standard format like stl::string or roguewave string?

regards,
raghu
 
B

benben

Hi,
Is there anything called Non Null Terminated string (may be in UTF or
something) i.e. a string which does not have a '\0' at the end to
terminate.
In that case how can the end be identified?

Yes. Take a look at std::basic_string<> template and std::string and
std::wstring typedef's.

Ben
 
R

Richard Herring

Raghavendra Mahuli said:
Hi,
Is there anything called Non Null Terminated string (may be in UTF or
something) i.e. a string which does not have a '\0' at the end to
terminate.

std::basic_string (and hence std::string and std::wstring) can contain
nulls and need not be terminated by one.
In that case how can the end be identified?

When constructing or assigning to it, by using the forms of the
constructor or the insert(), assign(), append() etc. functions which
take a pointer and a count, or two iterators. When obtaining its value,
by using the data() and size() functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top