Namespaces
Variants

std:: tolower (std::locale)

From cppreference.net
헤더에 정의됨 <locale>
template < class CharT >
CharT tolower ( CharT ch, const locale & loc ) ;

문자 ch 를 가능한 경우 소문자로 변환하며, 주어진 locale의 std::ctype 패싯에 지정된 변환 규칙을 사용합니다.

목차

매개변수

ch - character
loc - locale

반환값

로케일에 소문자 형태가 등록되어 있으면 ch 의 소문자 형태를 반환하고, 그렇지 않으면 ch 를 변경 없이 반환합니다.

참고 사항

이 함수는 1:1 문자 매핑만 수행할 수 있습니다. 예를 들어 그리스어 대문자 'Σ'는 단어 내 위치에 따라 두 가지 소문자 형태('σ'와 'ς')를 가집니다. 이런 경우 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 패싯을 사용하여 문자를 대문자로 변환
(함수 템플릿)
문자를 소문자로 변환
(함수)
와이드 문자를 소문자로 변환
(함수)