Apache C++ Standard Library Reference Guide

## toupper()

Library: Localization

    Function

- Local Index
- Summary
- Synopsis
- Description
- Example
- See Also
- Standards Conformance

### Local Index

No Entries

### Summary

Locale convenience function that converts a character to upper case

### Synopsis

    #include <locale>

    namespace std {
      template <class charT>
      charT toupper(charT c, const locale& loc);
    }

### Description

The `toupper()` function returns the parameter `c` after converting it to upper case. The conversion is made using the `ctype` facet from the `locale` parameter.

### Example

    //
    //  toupper.cpp
    //

    #include <iomanip>    // for setw
    #include <iostream>   // for cout, endl

    int main ()
    {
      std::cout << std::oct;
      std::cout.fill ('0');

      // compute tolower and toupper of printable ASCII characters
      for (int c = ' '; c != '~' + 1; ++c)
        std::cout << "std::toupper/lower ('\\" << std::setw (3)
                  << c
                  << "', std::locale ()) = '"
                  << std::toupper (char (c), std::cout.getloc ())
                  << "' / "
                  << std::tolower (char (c), std::cout.getloc ())
                  << "'\n";

        return 0;
    }
    Program Output:

    std::toupper/lower ('\040', std::locale ()) = ' ' /  '
    std::toupper/lower ('\041', std::locale ()) = '!' / !'
    std::toupper/lower ('\042', std::locale ()) = '"' / "'
    std::toupper/lower ('\043', std::locale ()) = '#' / #'
    std::toupper/lower ('\044', std::locale ()) = '$' / $'
    std::toupper/lower ('\045', std::locale ()) = '%' / %'
    std::toupper/lower ('\046', std::locale ()) = '&' / &'
    std::toupper/lower ('\047', std::locale ()) = ''' / ''
    std::toupper/lower ('\050', std::locale ()) = '(' / ('
    std::toupper/lower ('\051', std::locale ()) = ')' / )'
    std::toupper/lower ('\052', std::locale ()) = '*' / *'
    std::toupper/lower ('\053', std::locale ()) = '+' / +'
    std::toupper/lower ('\054', std::locale ()) = ',' / ,'
    std::toupper/lower ('\055', std::locale ()) = '-' / -'
    std::toupper/lower ('\056', std::locale ()) = '.' / .'
    std::toupper/lower ('\057', std::locale ()) = '/' / /'
    std::toupper/lower ('\060', std::locale ()) = '0' / 0'
    std::toupper/lower ('\061', std::locale ()) = '1' / 1'
    std::toupper/lower ('\062', std::locale ()) = '2' / 2'
    std::toupper/lower ('\063', std::locale ()) = '3' / 3'
    std::toupper/lower ('\064', std::locale ()) = '4' / 4'
    std::toupper/lower ('\065', std::locale ()) = '5' / 5'
    std::toupper/lower ('\066', std::locale ()) = '6' / 6'
    std::toupper/lower ('\067', std::locale ()) = '7' / 7'
    std::toupper/lower ('\070', std::locale ()) = '8' / 8'
    std::toupper/lower ('\071', std::locale ()) = '9' / 9'
    std::toupper/lower ('\072', std::locale ()) = ':' / :'
    std::toupper/lower ('\073', std::locale ()) = ';' / ;'
    std::toupper/lower ('\074', std::locale ()) = '<' / <'
    std::toupper/lower ('\075', std::locale ()) = '=' / ='
    std::toupper/lower ('\076', std::locale ()) = '>' / >'
    std::toupper/lower ('\077', std::locale ()) = '?' / ?'
    std::toupper/lower ('\100', std::locale ()) = '@' / @'
    std::toupper/lower ('\101', std::locale ()) = 'A' / a'
    std::toupper/lower ('\102', std::locale ()) = 'B' / b'
    std::toupper/lower ('\103', std::locale ()) = 'C' / c'
    std::toupper/lower ('\104', std::locale ()) = 'D' / d'
    std::toupper/lower ('\105', std::locale ()) = 'E' / e'
    std::toupper/lower ('\106', std::locale ()) = 'F' / f'
    std::toupper/lower ('\107', std::locale ()) = 'G' / g'
    std::toupper/lower ('\110', std::locale ()) = 'H' / h'
    std::toupper/lower ('\111', std::locale ()) = 'I' / i'
    std::toupper/lower ('\112', std::locale ()) = 'J' / j'
    std::toupper/lower ('\113', std::locale ()) = 'K' / k'
    std::toupper/lower ('\114', std::locale ()) = 'L' / l'
    std::toupper/lower ('\115', std::locale ()) = 'M' / m'
    std::toupper/lower ('\116', std::locale ()) = 'N' / n'
    std::toupper/lower ('\117', std::locale ()) = 'O' / o'
    std::toupper/lower ('\120', std::locale ()) = 'P' / p'
    std::toupper/lower ('\121', std::locale ()) = 'Q' / q'
    std::toupper/lower ('\122', std::locale ()) = 'R' / r'
    std::toupper/lower ('\123', std::locale ()) = 'S' / s'
    std::toupper/lower ('\124', std::locale ()) = 'T' / t'
    std::toupper/lower ('\125', std::locale ()) = 'U' / u'
    std::toupper/lower ('\126', std::locale ()) = 'V' / v'
    std::toupper/lower ('\127', std::locale ()) = 'W' / w'
    std::toupper/lower ('\130', std::locale ()) = 'X' / x'
    std::toupper/lower ('\131', std::locale ()) = 'Y' / y'
    std::toupper/lower ('\132', std::locale ()) = 'Z' / z'
    std::toupper/lower ('\133', std::locale ()) = '[' / ['
    std::toupper/lower ('\134', std::locale ()) = '\' / \'
    std::toupper/lower ('\135', std::locale ()) = ']' / ]'
    std::toupper/lower ('\136', std::locale ()) = '^' / ^'
    std::toupper/lower ('\137', std::locale ()) = '_' / _'
    std::toupper/lower ('\140', std::locale ()) = '`' / `'
    std::toupper/lower ('\141', std::locale ()) = 'A' / a'
    std::toupper/lower ('\142', std::locale ()) = 'B' / b'
    std::toupper/lower ('\143', std::locale ()) = 'C' / c'
    std::toupper/lower ('\144', std::locale ()) = 'D' / d'
    std::toupper/lower ('\145', std::locale ()) = 'E' / e'
    std::toupper/lower ('\146', std::locale ()) = 'F' / f'
    std::toupper/lower ('\147', std::locale ()) = 'G' / g'
    std::toupper/lower ('\150', std::locale ()) = 'H' / h'
    std::toupper/lower ('\151', std::locale ()) = 'I' / i'
    std::toupper/lower ('\152', std::locale ()) = 'J' / j'
    std::toupper/lower ('\153', std::locale ()) = 'K' / k'
    std::toupper/lower ('\154', std::locale ()) = 'L' / l'
    std::toupper/lower ('\155', std::locale ()) = 'M' / m'
    std::toupper/lower ('\156', std::locale ()) = 'N' / n'
    std::toupper/lower ('\157', std::locale ()) = 'O' / o'
    std::toupper/lower ('\160', std::locale ()) = 'P' / p'
    std::toupper/lower ('\161', std::locale ()) = 'Q' / q'
    std::toupper/lower ('\162', std::locale ()) = 'R' / r'
    std::toupper/lower ('\163', std::locale ()) = 'S' / s'
    std::toupper/lower ('\164', std::locale ()) = 'T' / t'
    std::toupper/lower ('\165', std::locale ()) = 'U' / u'
    std::toupper/lower ('\166', std::locale ()) = 'V' / v'
    std::toupper/lower ('\167', std::locale ()) = 'W' / w'
    std::toupper/lower ('\170', std::locale ()) = 'X' / x'
    std::toupper/lower ('\171', std::locale ()) = 'Y' / y'
    std::toupper/lower ('\172', std::locale ()) = 'Z' / z'
    std::toupper/lower ('\173', std::locale ()) = '{' / {'
    std::toupper/lower ('\174', std::locale ()) = '|' / |'
    std::toupper/lower ('\175', std::locale ()) = '}' / }'
    std::toupper/lower ('\176', std::locale ()) = '~' / ~'

### See Also

`tolower()`, locale, ctype

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 22.1.3.2