名前空間
変種
操作

std::ispunct(std::locale)

提供: cppreference.com
< cpp‎ | locale
 
 
 
ヘッダ <locale> で定義
template< class charT >
bool ispunct( charT ch, const locale& loc );

指定された文字が指定されたロケールの std::ctype ファセットによって句読点文字として分類されるかどうか調べます。

目次

[編集] 引数

ch - 文字
loc - ロケール

[編集] 戻り値

文字が句読点として分類される場合は true、そうでなければ false を返します。

[編集] 実装例

template< class charT >
bool ispunct( charT ch, const std::locale& loc ) {
    return std::use_facet<std::ctype<charT>>(loc).is(std::ctype_base::punct, ch);
}

[編集]

異なるロケールで ispunct() の使用をデモンストレーションします (OS 固有)。

#include <iostream>
#include <locale>
int main()
{
    const wchar_t c = L'\u214b'; // upside-down ampersand
 
    std::locale loc1("C");
    std::cout << "ispunct('⅋', C locale) returned "
               << std::boolalpha << std::ispunct(c, loc1) << '\n';
 
    std::locale loc2("en_US.UTF-8");
    std::cout << "ispunct('⅋', Unicode locale) returned "
              << std::boolalpha << std::ispunct(c, loc2) << '\n';
}

出力例:

isalpha('⅋', C locale) returned false
isalpha('⅋', Unicode locale) returned true

[編集] 関連項目

文字が句読点文字かどうか調べます
(関数) [edit]
ワイド文字が句読点文字かどうか調べます
(関数) [edit]