From: zade on
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 ?

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Mathias Gaunard on
On 25 f�v, 08:28, zade <zhaohongc...(a)gmail.com> wrote:
> 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 ?

Aren't they exactly the same thing?
The second one is probably a better way of saying it, since that means
you can just pass the size of your wchar_t buffer.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Ulrich Eckhardt on
zade wrote:
> 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?

The wording in the MSDN is ambiguous, agreed. However, look at the
description of the returnvalue: It talks about the required size in wide
characters, and that this is the number of converted multibyte characters.

Also, you can take a look at the declaration in newer SDKs. It contains a
compiler-specific annotation that says that the size of the buffer supplied
in parameter 1 is given as parameter 3.

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel Krügler on
On 25 Feb., 09:28, zade <zhaohongc...(a)gmail.com> wrote:
> 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".

The C(99) standard says:

"[..] and stores not more than count wide characters into the array
pointed to by wcstr"

adapted to the symbols used in above declaration. This basically
means that the destination buffer wcstr must have at least
a capacity of count characters of the corresponding character
type wchar_t.

> so, which one is right?

Documentation is an QoI issue, but in doubt the ISO standard
wording is to consider.

> and should I make some workrounds to call this function in
> different OS ?

I do not understand why OS-specific workarounds should be
required. Could you elaborate?

HTH & Greetings from Bremen,

Daniel Kr�gler


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]