std::tolower(std::locale)
From cppreference.com
| ヘッダー <locale> で定義 |
||
| template< class CharT > CharT tolower( CharT ch, const locale& loc ); |
||
指定されたロケールの std::ctype ファセットによって指定された変換規則を使用して、可能であれば文字 ch を小文字に変換します。
目次 |
[編集] パラメータ
| 文字 | - | 文字 |
| loc | - | locale |
[編集] 戻り値
ロケールで小文字の形式がリストされている場合は、その小文字の形式を返します。それ以外の場合は、ch を変更せずに返します。
[編集] 注
この関数では1対1の文字マッピングのみが実行できます。たとえば、ギリシャ語の大文字 'Σ' には、単語内の位置に応じて 'σ' と 'ς' の 2 つの小文字の形式があります。この場合、正しい小文字の形式を取得するために std::tolower を呼び出すことはできません。
[編集] 実装例
template<class CharT> CharT tolower(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).tolower(ch); } |
[編集] 例
このコードを実行
#include <cwctype> #include <iostream> #include <locale> int main() { wchar_t c = L'\u0190'; // Latin capital open E ('Ɛ') std::cout << std::hex << std::showbase; std::cout << "in the default locale, tolower(" << (std::wint_t)c << ") = " << (std::wint_t)std::tolower(c, std::locale()) << '\n'; std::cout << "in Unicode locale, tolower(" << (std::wint_t)c << ") = " << (std::wint_t)std::tolower(c, std::locale("en_US.utf8")) << '\n'; }
実行結果の例
in the default locale, tolower(0x190) = 0x190 in Unicode locale, tolower(0x190) = 0x25b
[編集] 関連項目
| ロケールのctypeファセットを使用して文字を大文字に変換する (関数テンプレート) | |
| 文字を小文字に変換する (関数) | |
| ワイド文字を小文字に変換する (関数) |