_setmbcp

Sets a new multibyte code page.

int_setmbcp(intcodepage**);**

Routine Required Header Compatibility
_setmbcp <mbctype.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

_setmbcp returns 0 if the code page is set successfully. If an invalid code page value is supplied for codepage, the function returns –1 and the code page setting is unchanged.

Parameter

codepage

New code page setting for locale-independent multibyte routines

Remarks

The _setmbcp function specifies a new multibyte code page. By default, the run-time system automatically sets the multibyte code page to the system-default ANSI code page. The multibyte code page setting affects all multibyte routines that are not locale-dependent. However, it is possible to instruct _setmbcp to use the code page defined for the current locale (see the following list of manifest constants and associated behavior results). For a list of the multibyte routines that are dependent on the locale code page rather than the multibyte code page, see Interpretation of Multibyte-Character Sequences.

The multibyte code page also affects multibyte-character processing by the following run-time library routines:

_exec functions _mktemp _stat
_fullpath _spawn functions _tempnam
_makepath _splitpath tmpnam

In addition, all run-time library routines that receive multibyte-character argv or envp program arguments as parameters (such as the _exec and _spawn families) process these strings according to the multibyte code page. Hence these routines are also affected by a call to _setmbcp that changes the multibyte code page.

The codepage argument can be set to any of the following values:

  • _MB_CP_ANSI   Use ANSI code page obtained from operating system at program startup

  • _MB_CP_LOCALE   Use the current locale’s code page obtained from a previous call to setlocale

  • _MB_CP_OEM   Use OEM code page obtained from operating system at program startup

  • _MB_CP_SBCS   Use single-byte code page. When the code page is set to _MB_CP_SBCS, a routine such as _ismbblead always returns false.

  • Any other valid code page value, regardless of whether the value is an ANSI, OEM, or other operating-sytem – supported code page.

See Also   _getmbcp, setlocale