The facet codecvt is responsible for translating internal characters ( wchar_t) to/from external char's in a file.
There are several techniques for representing a series of wchar_t's with a series of char's. The codecvt_byname facet can be used to select among several of the encodings. If you construct codecvt_byname with a const char* that refers to a file, then that file is scanned by codecvt_byname's constructor for information to customize the encoding.
codecvt_byname<wchar_t, char, std::mbstate_t>
cvt("en_US");
If the file "en_US" exists, has codecvt data in it, and there are no syntax errors in the data, then cvt will behave as dictated by that data. If the file exists, but does not have codecvt data in it, then the facet will behave as if it were constructed with "C". If the file has codecvt data in it, but there is a syntax error in the data, or if the file does not exist, then a std::runtime_error is thrown.
For codecvt_byname<char, char, mbstate_t>, the codecvt data section begins with:
$codecvt_narrow
For codecvt_byname<wchar_t, char, mbstate_t>, the codecvt data section begins with:
$codecvt_wide
Although $codecvt_narrow is a valid data section, it really does not do anything. The codecvt_byname<char, char, mbstate_t> facet does not add any functionality beyond codecvt<char, char, mbstate_t>. This facet is a degenerate case of noconv (no conversion). This can be represented in the locale data file as:
$codecvt_narrow
noconv
The facet codecvt_byname<wchar_t, char, mbstate_t> is much more interesting. After the data section introduction ($codecvt_wide), one of these keywords can appear:
These keywords will be parsed as strings according to the rules for Strings and Characters in Locale Data Files .