std::toupper(std::locale)
From cppreference.com
| ヘッダー <locale> で定義 |
||
| template< class CharT > CharT toupper( CharT ch, const locale& loc ); |
||
指定されたロケールの std::ctype ファセットで指定された変換規則を使用して、文字 ch を可能であれば大文字に変換します。
目次 |
[編集] パラメータ
| 文字 | - | 文字 |
| loc | - | locale |
[編集] 戻り値
ロケールに大文字の形式がリストされている場合は、その大文字の形式を返します。それ以外の場合は、ch を変更せずに返します。
[編集] 注意
この関数で実行できるのは 1対1 の文字マッピングのみです。たとえば、「ß」の大文字形式は(いくつかの例外を除いて)2文字の文字列「SS」ですが、これは std::toupper では取得できません。
[編集] 実装例
template<class CharT> CharT toupper(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).toupper(ch); } |
[編集] 例
このコードを実行
#include <cwctype> #include <iostream> #include <locale> int main() { wchar_t c = L'\u017f'; // Latin small letter Long S ('ſ') std::cout << std::hex << std::showbase; std::cout << "in the default locale, toupper(" << (std::wint_t)c << ") = " << (std::wint_t)std::toupper(c, std::locale()) << '\n'; std::cout << "in Unicode locale, toupper(" << (std::wint_t)c << ") = " << (std::wint_t)std::toupper(c, std::locale("en_US.utf8")) << '\n'; }
実行結果の例
in the default locale, toupper(0x17f) = 0x17f in Unicode locale, toupper(0x17f) = 0x53
[編集] 関連項目
ロケールの ctype ファセットを使用して文字を小文字に変換する(関数テンプレート) | |
| 文字を大文字に変換する (関数) | |
| ワイド文字を大文字に変換する (関数) |