c++visual-studiovisual-c++msdntr24731

"wcs" and "_w" and "_mbs" prefix in Visual Studio


I am a little confused with respect to the difference in the functions which are defined with/without the wcs/_w/_mbs prefix.
For Example:

The fopen function opens the file that is specified by filename. _wfopen is a wide-character version of fopen; the arguments to _wfopen are wide-character strings. Otherwise, _wfopen and fopen behave identically.

I just had a doubt whether there is any platform dependence to windows associated with the addition of the "_w" prefix.

wcscpy and _mbscpy are, respectively, wide-character and multibyte-character versions of strcpy.

Again there is a doubt if the addition of "wcs" or "_mbs" is platform dependent.

EDIT:

WideCharToMultiByte is not a C Runtime function, it's a Windows API,hence it is platform dependent

It was nonstandard but was standardized in C11 Annex K.


Solution

  • The wcs* functions like wcscpy are part of the C Standard Library. The _wfopen function and other _w* functions are extensions, as are the multibyte string functions like _mbscpy.

    For the most part, Visual C++ C Runtime (CRT) functions that have a leading underscore are extensions; functions that do not have a leading underscore are part of the C Standard Library.

    There are two main exceptions, where extensions may not have leading underscores: