std:: isprint (std::locale)
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<locale>
|
||
|
template
<
class
CharT
>
bool isprint ( CharT ch, const locale & loc ) ; |
||
指定された文字が、指定されたロケールの std::ctype ファセットによって印字可能文字(スペースを含む)として分類されるかどうかをチェックします。
目次 |
パラメータ
| ch | - | 文字 |
| loc | - | ロケール |
戻り値
文字が印字可能として分類される場合は true を返し、それ以外の場合は false を返します。
実装例
template<class CharT> bool isprint(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::print, ch); } |
` タグ内のC++コードは翻訳せず、元のフォーマットを保持しています。
例
異なるロケール(OS固有)での
isprint()
の使用例を示します。
このコードを実行
#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'; }
出力例:
isprint('™', C locale) returned false
isprint('™', Unicode locale) returned true
関連項目
|
文字が表示可能文字かどうかをチェックする
(関数) |
|
|
ワイド文字が表示可能文字かどうかをチェックする
(関数) |