the means of mbstowcs parameter

Z

zade

the function prototype is like below:

size_t mbstowcs( wchar_t* wcstr, const char* mbstr, size_t count )

in MSDN, parameter 'count ' means :"The number of multibyte
characters to convert".

it cplusplus.com(like unix and linux man page), parameter 'count '
means :"Maximum number of wchar_t characters to be interpreted".

so, which one is right? and should I make some workrounds to call this
function in different OS ?
 
Z

zade

I fail to see the difference. Different terms, same meaning.

--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---

In MSDN, it means the number of multibyte characters; while in some
cases, count = strlen(mbstr).
In others, it means the capacity of the wcstr.
Let me give an example:

In MSDN:
const char* mstr = "abc123";
const static size_t MAX_LEN = 100;
const wchar_t wstr[MAX_LEN];
mbstowcs(mstr,wstr,strlen(mstr));

In others:
const char* mstr = "abc123";
const static size_t MAX_LEN = 100;
const wchar_t wstr[MAX_LEN];
mbstowcs(mstr,wstr,MAX_LEN);

Is that OK?
 
I

Ian Collins

zade said:
In MSDN, it means the number of multibyte characters; while in some
cases, count = strlen(mbstr).
In others, it means the capacity of the wcstr.
Let me give an example:

In MSDN:
const char* mstr = "abc123";
const static size_t MAX_LEN = 100;
const wchar_t wstr[MAX_LEN];
mbstowcs(mstr,wstr,strlen(mstr));

In others:
const char* mstr = "abc123";
const static size_t MAX_LEN = 100;
const wchar_t wstr[MAX_LEN];
mbstowcs(mstr,wstr,MAX_LEN);

Is that OK?

See my answer in c.l.c.
 

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

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top