public member function
<locale>
std::ctype::widen
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
- ctype::narrow
- Narrow character(s) (public member function)