std::ctype<CharT>::tolower, std::ctype<CharT>::do_tolower
From cppreference.com
| ヘッダー <locale> で定義 |
||
| public: CharT tolower( CharT c ) const; |
(1) | |
| public: const CharT* tolower( CharT* beg, const CharT* end ) const; |
(2) | |
| protected: virtual CharT do_tolower( CharT c ) const; |
(3) | |
| protected: virtual const CharT* do_tolower( CharT* beg, const CharT* end ) const; |
(4) | |
1,2) 公開メンバ関数。最も派生したクラスのprotected仮想メンバ関数
do_tolowerを呼び出します。3) このロケールによって定義されている場合、文字cを小文字に変換します。
4) 文字配列
[beg, end)内の、小文字形式が存在するすべての文字を、その小文字形式に置き換えます。目次 |
[編集] パラメータ
| c | - | 変換する文字 |
| beg | - | 変換する文字配列の最初の文字へのポインタ |
| end | - | 変換する文字配列の終端の次を指すポインタ |
[編集] 戻り値
1,3) 小文字。このロケールによって小文字形式がリストされていない場合はc。
2,4)
end[編集] 注記
この関数では1対1の文字マッピングのみが可能です。例えば、ギリシャ語の大文字「Σ」は、単語内の位置によって2つの小文字形式「σ」と「ς」を持ちます。このような場合、do_tolowerの呼び出しでは正しい小文字形式を取得することはできません。
[編集] 例
このコードを実行
#include <iostream> #include <locale> void try_lower(const std::ctype<wchar_t>& f, wchar_t c) { wchar_t up = f.tolower(c); if (up != c) std::wcout << "Lower case form of \'" << c << "' is " << up << '\n'; else std::wcout << '\'' << c << "' has no lower case form\n"; } int main() { std::locale::global(std::locale("en_US.utf8")); std::wcout.imbue(std::locale()); std::wcout << "In US English UTF-8 locale:\n"; auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale()); try_lower(f, L'Σ'); try_lower(f, L'Ɛ'); try_lower(f, L'A'); std::wstring str = L"HELLo, wORLD!"; std::wcout << "Lowercase form of the string '" << str << "' is "; f.tolower(&str[0], &str[0] + str.size()); std::wcout << '\'' << str << "'\n"; }
出力
In US English UTF-8 locale: Lower case form of 'Σ' is σ Lower case form of 'Ɛ' is ɛ Lower case form of 'A' is a Lowercase form of the string 'HELLo, wORLD!' is 'hello, world!'
[編集] 関連項目
do_toupperを呼び出します。(公開メンバ関数) | |
| 文字を小文字に変換する (関数) | |
| ワイド文字を小文字に変換する (関数) |