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

std::isprint(std::locale)

Defined in header <locale>

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

检查给定的字符是否按给定的地区%27s分类为可打印字符%28,包括空格%29std::ctype小面。

参数

ch

-

character

loc

-

locale

返回值

回报true如果该字符被归类为可打印的,false否则。

可能的实施

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

*。

演示在不同的区域设置中使用isprint%28%29和特定于%28 OS的%29的用法。

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
int main()
{
    const wchar_t c = L'\u2122'; // trademark sign
 
    std::locale loc1("C");
    std::cout << "isprint('™', C locale) returned "
               << std::boolalpha << std::isprint(c, loc1) << '\n';
 
    std::locale loc2("en_US.UTF-8");
    std::cout << "isprint('™', Unicode locale) returned "
              << std::boolalpha << std::isprint(c, loc2) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
isprint('™', C locale) returned false
isprint('™', Unicode locale) returned true

二次

另见

isprint

checks if a character is a printing character (function)

iswprint

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

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

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

扫码关注腾讯云开发者

领取腾讯云代金券