首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::isspace(std::locale)

Defined in header <locale>

?

?

template< class charT > bool isspace( charT ch, const locale& loc );

?

?

检查给定字符是否被给定的区域设置%27s Ctype facet归类为空白字符。

参数

ch

-

character

loc

-

locale

返回值

回报true如果字符被归类为空白字符,false否则。

可能的实施

模板<类图表>bool isspace%28图表ch,Const std::locale&loc%29{返回std::use[医]facet<std::Ctype<charT>>%28 loc%29 is%28 std::Ctype[医]基::空格,ch%29;}

*。

演示在不同地区使用isspace%28%29的方法--特定于%28 OS的%29。

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
 
void try_with(wchar_t c, const char* loc)
{
    std::wcout << "isspace('" << c << "', locale(\"" << loc << "\")) returned "
               << std::boolalpha << std::isspace(c, std::locale(loc)) << '\n';
}
 
int main()
{
    const wchar_t EM_SPACE = L'\u2003'; // Unicode character 'EM SPACE'
    try_with(EM_SPACE, "C");
    try_with(EM_SPACE, "en_US.UTF8");
}

二次

产出:

二次

代码语言:javascript
复制
isspace(' ', locale("C")) returned false
isspace(' ', locale("en_US.UTF8")) returned true

二次

另见

isspace

checks if a character is a space character (function)

iswspace

checks if a wide character is a space character (function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com