Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
locale
has_facet
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
locale
tolower
toupper
use_facet
standard facets:
codecvt
codecvt_base
codecvt_byname
collate
collate_byname
ctype
ctype_base
ctype_byname
messages
messages_base
messages_byname
moneypunct
moneypunct_byname
money_base
money_get
money_put
numpunct
numpunct_byname
num_get
num_put
time_base
time_get
time_get_byname
time_put
time_put_byname


toupper

function template
<locale>
template <class charT>
  charT toupper ( charT c, const locale& loc );

Convert lowercase letter to uppercase using locale

Converts parameter c to its uppercase equivalent if c is a lowercase letter and has an uppercase equivalent using ctype facet of locale loc. If no such conversion is possible, the value returned is c unchanged.

This function returns the same as a call to:

 
use_facet < ctype<charT> > (loc).toupper (c)


This function replicates the functionality of its C-library equivalent toupper. See toupper for more info.

Parameters

c
Character to be converted.
loc
Locale to be used. Shall have facet ctype present.

Template parameter charT is the character type.

Return Value

The uppercase equivalent to c, if any. Or c unchanged.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// toupper example (C++)
#include <iostream>
#include <string>
#include <locale>
using namespace std;
int main ()
{
  locale loc;
  string str="Test String.\n";
  for (size_t i=0; i<str.length(); ++i)
    cout << toupper(str[i],loc);
  return 0;
}


Output:

TEST STRING.

See also