GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::btowc(3) C++ Standard Libary std::btowc(3)

std::btowc - std::btowc


Defined in header <cwchar>
std::wint_t btowc( int c );


Widens a single-byte character c to its wide character equivalent.


Most multibyte character encodings use single-byte codes to represent the characters
from the ASCII character set. This function may be used to convert such characters
to wchar_t.


c - single-byte character to widen


WEOF if c is EOF.


Wide character representation of c if (unsigned char)c is a valid single-byte
character in the initial shift state, WEOF otherwise.

// Run this code


#include <iostream>
#include <cwchar>
#include <clocale>


void try_widen(char c)
{
std::wint_t w = std::btowc(c);
if(w != WEOF)
std::cout << "The single-byte character " << +(unsigned char)c
<< " widens to " << +w << '\n';
else
std::cout << "The single-byte character " << +(unsigned char)c
<< " failed to widen\n";
}


int main()
{
std::setlocale(LC_ALL, "lt_LT.iso88594");
std::cout << std::hex << std::showbase << "In Lithuanian ISO-8859-4 locale:\n";
try_widen('A');
try_widen('\xdf'); // German letter ß (U+00df) in ISO-8859-4
try_widen('\xf9'); // Lithuanian letter ų (U+0173) in ISO-8859-4


std::setlocale(LC_ALL, "lt_LT.utf8");
std::cout << "In Lithuanian UTF-8 locale:\n";
try_widen('A');
try_widen('\xdf');
try_widen('\xf9');
}


In Lithuanian ISO-8859-4 locale:
The single-byte character 0x41 widens to 0x41
The single-byte character 0xdf widens to 0xdf
The single-byte character 0xf9 widens to 0x173
In Lithuanian UTF-8 locale:
The single-byte character 0x41 widens to 0x41
The single-byte character 0xdf failed to widen
The single-byte character 0xf9 failed to widen


wctob narrows a wide character to a single-byte narrow character, if possible
(function)
do_widen converts a character or characters from char to charT
[virtual] (virtual protected member function of std::ctype<CharT>)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.