函式模板
<locale>

std::tolower

template <class charT>  charT tolower (charT c, const locale& loc);
使用 locale 將大寫字母轉換為小寫字母
如果 c 是一個大寫字母並且有一個對應的小寫字母,則將 c 轉換為其小寫等效項,轉換方式由 locale 的 ctype 方面確定。如果無法進行此類轉換,則返回的 c 不變。

此函式返回的結果與呼叫 ctype::tolower 相同,如

1
use_facet < ctype<charT> > (loc).tolower (c)

此函式模板過載了 C 函式 tolower(定義在 <cctype> 中)。

引數

c
要轉換的字元。
loc
要使用的 locale。它必須具有 ctype 方面。

模板引數 charT 是字元型別。

返回值

c 對應的小寫字元,如果存在的話。否則 c 不變。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
// tolower example (C++)
#include <iostream>       // std::cout
#include <string>         // std::string
#include <locale>         // std::locale, std::tolower

int main ()
{
  std::locale loc;
  std::string str="Test String.\n";
  for (std::string::size_type i=0; i<str.length(); ++i)
    std::cout << std::tolower(str[i],loc);
  return 0;
}

輸出

test string.


資料競爭

將訪問 loc 及其 ctype 方面。

異常安全

強保證:如果丟擲異常,則沒有效果。

另見