对多字节字符串前导字节和结尾字节执行上下文相关测试,并确定给定子字符串指针指向前导字节还是结尾字节。
重要
此 API 不能用于在 Windows 运行时中执行的应用程序。 有关详细信息,请参阅通用 Windows 平台应用中不支持的 CRT 函数。
语法
int _ismbslead(
const unsigned char *str,
const unsigned char *current
);
int _ismbstrail(
const unsigned char *str,
const unsigned char *current
);
int _ismbslead_l(
const unsigned char *str,
const unsigned char *current,
_locale_t locale
);
int _ismbstrail_l(
const unsigned char *str,
const unsigned char *current,
_locale_t locale
);
参数
str
指向字符串开头或之前已知的前导字节的指针。
current
指向要测试的字符串中位置的指针。
locale
要使用的区域设置。
返回值
如果字符是前导字节,则 _ismbslead
将返回 -1;如果字符为结尾字节,则 _ismbstrail
将返回 -1。 如果输入字符串有效,但不是前导字节也不是结尾字节,则这些函数将返回零。 如果任一自变量为 NULL
,则将调用无效的参数处理程序,如参数验证中所述。 如果允许执行继续,则这些函数将返回 NULL
并将 errno
设置为 EINVAL
。
备注
_ismbslead
和 _ismbstrail
慢于 _ismbblead
和 _ismbbtrail
版本,因为前二者会将字符串文本考虑进去。
前缀为 _l
的函数的版本相同,但其依赖区域设置的行为除外,它们可使用已传入的区域设置代替当前区域设置。 有关详细信息,请参阅 Locale。
默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态。
要求
例程 | 必需的标头 | 可选标头 |
---|---|---|
_ismbslead |
<mbctype.h> 或 <mbstring.h> | <ctype.h>、* <limits.h>、<stdlib.h> |
_ismbstrail |
<mbctype.h> 或 <mbstring.h> | <ctype.h>、* <limits.h>、<stdlib.h> |
_ismbslead_l |
<mbctype.h> 或 <mbstring.h> | <ctype.h>、* <limits.h>、<stdlib.h> |
_ismbstrail_l |
<mbctype.h> 或 <mbstring.h> | <ctype.h>、* <limits.h>、<stdlib.h> |
* 适用于测试条件的清单常数。
有关兼容性的详细信息,请参阅 兼容性。