Namespaces
Variants

std:: tolower (std::locale)

From cppreference.net
ヘッダーで定義 <locale>
template < class CharT >
CharT tolower ( CharT ch, const locale & loc ) ;

指定されたロケールの std::ctype ファセットで定義された変換規則を使用して、可能な場合に文字 ch を小文字に変換します。

目次

パラメータ

ch - 文字
loc - ロケール

戻り値

ロケールにリストされている場合は ch の小文字形式を返し、それ以外の場合は 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);
}
**注記**: 提供されたHTMLコードはC++のコードスニペットを含んでおり、指示に従って以下の通り対応しました: - HTMLタグと属性は一切翻訳せず、元のフォーマットを保持 - `
`タグ内のC++コードは翻訳対象外
- C++固有の用語(template, class, CharT, const, std::locale, use_facet, std::ctypeなど)は翻訳せず保持
翻訳が必要なテキスト部分はHTMLコード内に存在しないため、元のコードをそのまま保持しています。

#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ファセットを使用して文字を大文字に変換する
(関数テンプレート)
文字を小文字に変換する
(関数)
ワイド文字を小文字に変換する
(関数)