_strupr_s、_strupr_s_l、_mbsupr_s、_mbsupr_s_l、_wcsupr_s、_wcsupr_s_l_strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_l

通过使用当前区域设置或传入的指定区域设置将字符串转换为大写。Converts a string to uppercase, by using the current locale or a specified locale that's passed in. 这些版本的 _strupr、_strupr_l、_mbsupr、_mbsupr_l、_wcsupr_l、_wcsupr 具有安全增强功能,如 CRT 的安全增强功能中所述。These versions of _strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr have security enhancements, as described in Security Features in the CRT.

重要

_mbsupr_s_mbsupr_s_l不能用于在 Windows 运行时中执行的应用程序。_mbsupr_s and _mbsupr_s_l cannot be used in applications that execute in the Windows Runtime. 有关详细信息,请参阅通用 Windows 平台应用中不支持的 CRT 函数For more information, see CRT functions not supported in Universal Windows Platform apps.

语法Syntax

errno_t _strupr_s(
   char *str,
   size_t numberOfElements
);
errno_t _wcsupr_s(
   wchar_t * str,
   size_t numberOfElements
);
errno_t _strupr_s_l(
   char * str,
   size_t numberOfElements,
   _locale_t locale
);
errno_t _wcsupr_s_l(
   wchar_t * str,
   size_t numberOfElements,
   _locale_t locale
);
errno_t _mbsupr_s(
   unsigned char *str,
   size_t numberOfElements
);
errno_t _mbsupr_s_l(
   unsigned char *str,
   size_t numberOfElements,
   _locale_t locale
);
template <size_t size>
errno_t _strupr_s(
   char (&str)[size]
); // C++ only
template <size_t size>
errno_t _wcsupr_s(
   wchar_t (&str)[size]
); // C++ only
template <size_t size>
errno_t _strupr_s_l(
   char (&str)[size],
   _locale_t locale
); // C++ only
template <size_t size>
errno_t _wcsupr_s_l(
   wchar_t (&str)[size],
   _locale_t locale
); // C++ only
template <size_t size>
errno_t _mbsupr_s(
   unsigned char (&str)[size]
); // C++ only
template <size_t size>
errno_t _mbsupr_s_l(
   unsigned char (&str)[size],
   _locale_t locale
); // C++ only

参数Parameters

strstr
大写字符串。String to capitalize.

numberOfElementsnumberOfElements
缓冲区的大小。Size of the buffer.

localelocale
要使用的区域设置。The locale to use.

返回值Return Value

如果成功,则返回零;如果失败,则返回非零错误代码。Zero if successful; a non-zero error code on failure.

这些函数验证其参数。These functions validate their parameters. 如果strNULL指针,无效参数处理程序调用中所述,参数验证If str is a NULL pointer, the invalid parameter handler is invoked, as described in Parameter Validation . 如果允许执行继续,函数将返回EINVAL并设置errnoEINVALIf execution is allowed to continue, the functions return EINVAL and set errno to EINVAL. 如果numberOfElements小于长度的字符串,这些函数返回ERANGE并设置errnoERANGEIf numberOfElements is less than the length of the string, the functions return ERANGE and set errno to ERANGE.

备注Remarks

_Strupr_s函数将转换时,就地情况下,每个小写字母str为大写形式。The _strupr_s function converts, in place, each lowercase letter in str to uppercase. _wcsupr_s是宽字符版本的 _strupr_s_wcsupr_s is the wide-character version of _strupr_s. _mbsupr_s是多字节字符版本的 _strupr_s_mbsupr_s is the multi-byte character version of _strupr_s.

转换由LC_CTYPE类别设置的区域设置。The conversion is determined by the LC_CTYPE category setting of the locale. 其他字符不受影响。Other characters are not affected. 有关详细信息LC_CTYPE,请参阅setlocaleFor more information on LC_CTYPE, see setlocale. 版本的这些功能,而不必 _l后缀使用当前区域设置; 与前景 _l后缀是相同,只不过它们使用传递的区域设置。The versions of these functions without the _l suffix use the current locale; the visions with the _l suffix are identical except that they use the locale passed in instead. 有关详细信息,请参阅 LocaleFor more information, see Locale.

在 C++ 中,使用这些函数由模板重载简化;重载可以自动推导出缓冲区长度 (不再需要指定大小自变量),并且它们可以自动用以更新、更安全的对应物替换旧的、不安全的函数。In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically (eliminating the need to specify a size argument) and they can automatically replace older, non-secure functions with their newer, secure counterparts. 有关详细信息,请参阅 Secure Template OverloadsFor more information, see Secure Template Overloads.

这些函数的调试版本首先用 0xFD 填充缓冲区。The debug versions of these functions first fill the buffer with 0xFD. 若要禁用此行为,请使用 _CrtSetDebugFillThresholdTo disable this behavior, use _CrtSetDebugFillThreshold.

一般文本例程映射Generic-Text Routine Mappings

TCHAR.H 例程TCHAR.H routine 未定义 _UNICODE 和 _MBCS_UNICODE & _MBCS not defined 已定义 _MBCS_MBCS defined 已定义 _UNICODE_UNICODE defined
_tcsupr_s_tcsupr_s _strupr_s_strupr_s _mbsupr_s_mbsupr_s _wcsupr_s_wcsupr_s
_tcsupr_s_l_tcsupr_s_l _strupr_s_l_strupr_s_l _mbsupr_s_l_mbsupr_s_l _wcsupr_s_l_wcsupr_s_l

要求Requirements

例程Routine 必需的标头Required header
_strupr_s_strupr_s_l_strupr_s, _strupr_s_l <string.h><string.h>
_wcsupr_s_wcsupr_s_l_mbsupr_s_mbsupr_s_l_wcsupr_s, _wcsupr_s_l, _mbsupr_s, _mbsupr_s_l <string.h> 或 <wchar.h><string.h> or <wchar.h>

有关其他兼容性信息,请参阅 兼容性For additional compatibility information, see Compatibility.

示例Example

请参阅 _strlwr_s、_strlwr_s_l、_mbslwr_s、_mbslwr_s_l、_wcslwr_s、_wcslwr_s_l 中的示例。See the example for _strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_l .

请参阅See also

区域设置Locale
多字节字符序列的解释Interpretation of Multibyte-Character Sequences
字符串操作String Manipulation
_strlwr_s、_strlwr_s_l、_mbslwr_s、_mbslwr_s_l、_wcslwr_s、_wcslwr_s_l_strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_l