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
ctype
ctype::ctype
public member functions:
ctype::is
ctype::narrow
ctype::scan_is
ctype::scan_not
ctype::tolower
ctype::toupper
ctype::widen
public member types:
ctype::char_type
ctype::mask
protected members:
ctype::do_is
ctype::do_narrow
ctype::do_scan_is
ctype::do_scan_not
ctype::do_tolower
ctype::do_toupper
ctype::do_widen
ctype::~ctype


ctype::widen

public member function
      charT widen (char c) const;
const char* widen (const char* low, const char* high, charT* to) const;

Widen character(s)

The first version returns the transformation of c to its equivalent of character type charT (where charT is the template parameter of ctype, generally a wide character type).

The second version fills the range starting at to with the transformations of the char values in the range [low,high).

The transformation applied is the simplest reasonable transformation from char values to their corresponding values of the destination type (which is the type of ctype's template parameter, charT).

The transformation preserves the character categories (as specified by ctype::mask).

During its operation, this function simply calls the virtual protected member ctype::do_widen, which is the member function in charge of performing the actions described above.

Parameters

c
char value to transform.
Notice that the type of this parameter is the fundamental type char, independently of the character type the facet uses.
low, high
Pointer to the initial and final char values of a sequence. The range used is [low,high), which contains all the values between low and high, including the value pointed by low but not the value pointed by high.
Notice that the type of the elements in the range is the fundamental type char, independently of the character type the facet uses.
to
Pointer to a range of elements of type charT able to store at least as many elements as the range between low and high.
charT is the template parameter of ctype (i.e., the facet's character type).

Return value

The first version returns the transformation of c.
charT is the template parameter of ctype (i.e., the facet's character type).

The second version returns high.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// ctype::widen example
#include <iostream>
#include <locale>
using namespace std;
int main ()
{
  locale loc;
  char narrow_phrase[] = "Seventy-seven foxes";
  wchar_t wide_phrase[sizeof(narrow_phrase)];
  cout << "The first wide character is: ";
  wchar_t wc = use_facet< ctype<wchar_t> >(loc).widen ( *narrow_phrase );
  wcout << wc << endl;
  cout << "The wide-character phrase is: ";
  use_facet< ctype<wchar_t> >(loc).widen ( narrow_phrase, narrow_phrase+sizeof(narrow_phrase), wide_phrase );
  wcout << wide_phrase << endl;
  return 0;
}


Output:

The first wide character is: S
The wide-character phrase is: Seventy-seven foxes

See also