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::codecvt_mode(3) C++ Standard Libary std::codecvt_mode(3)

std::codecvt_mode - std::codecvt_mode


Defined in header <codecvt>
enum codecvt_mode {


consume_header = 4, (since C++11)
generate_header = 2, (deprecated in C++17)
little_endian = 1


};


The facets std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16 accept
an optional value of type std::codecvt_mode as a template argument, which specifies
optional features of the unicode string conversion.


Defined in header <locale>
Value Meaning
little_endian assume the input is in little-endian byte order (applies to UTF-16
input only, the default is big-endian)
consume the byte order mark, if present at the start of input
consume_header sequence, and (in case of UTF-16), rely on the byte order it
specifies for decoding the rest of the input
generate_header output the byte order mark at the start of the output sequence


The recognized byte order marks are:


0xfe 0xff UTF-16 big-endian
0xff 0xfe UTF-16 little-endian
0xef 0xbb 0xbf UTF-8 (no effect on endianness)


If std::consume_header is not selected when reading a file beginning with byte order
mark, the Unicode character U+FEFF (Zero width non-breaking space) will be read as
the first character of the string content.


The following example demonstrates consuming the UTF-8 BOM

// Run this code


#include <fstream>
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>


int main()
{
// UTF-8 data with BOM
std::ofstream("text.txt") << u8"\ufeffz\u6c34\U0001d10b";
// read the UTF8 file, skipping the BOM
std::wifstream fin("text.txt");
fin.imbue(std::locale(fin.getloc(),
new std::codecvt_utf8<wchar_t, 0x10ffff, std::consume_header>));
for (wchar_t c; fin.get(c); )
std::cout << std::hex << std::showbase << c << '\n';
}


0x7a
0x6c34
0x1d10b


converts between character encodings, including UTF-8,
codecvt UTF-16, UTF-32
(class template)
codecvt_utf8 converts between UTF-8 and UCS2/UCS4
(C++11)(deprecated in C++17) (class template)
codecvt_utf16 converts between UTF-16 and UCS2/UCS4
(C++11)(deprecated in C++17) (class template)
codecvt_utf8_utf16 converts between UTF-8 and UTF-16
(C++11)(deprecated in C++17) (class template)

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.