, , . , , Ive , , . , , ( - , shift-JIS, UTF-8 ), . Microsoft , Ive lib++.
#if _WIN32 || _WIN64
# define _WIN32_WINNT 0x0A00
# define NTDDI_VERSION 0x0A000002
# include <sdkddkver.h>
#else
# define _XOPEN_SOURCE 700
# define _POSIX_C_SOURCE 200809L
#endif
#include <iostream>
#include <locale>
#include <locale.h>
#include <stdlib.h>
#include <string>
#ifndef MS_STDLIB_BUGS
# if ( _MSC_VER || __MINGW32__ || __MSVCRT__ )
# define MS_STDLIB_BUGS 1
# else
# define MS_STDLIB_BUGS 0
# endif
#endif
#if MS_STDLIB_BUGS
# include <io.h>
# include <fcntl.h>
#endif
using std::endl;
using std::istream;
using std::wcin;
using std::wcout;
void init_locale(void)
{
#if MS_STDLIB_BUGS
constexpr char cp_utf16le[] = ".1200";
setlocale( LC_ALL, cp_utf16le );
_setmode( _fileno(stdout), _O_WTEXT );
_setmode( _fileno(stdin), _O_WTEXT );
#else
constexpr char locale_name[] = "";
setlocale( LC_ALL, locale_name );
std::locale::global(std::locale(locale_name));
wcout.imbue(std::locale());
wcin.imbue(std::locale());
#endif
}
int main(void)
{
init_locale();
static constexpr size_t bufsize = 1024;
std::wstring input;
input.reserve(bufsize);
while ( wcin >> input )
wcout << input << endl;
return EXIT_SUCCESS;
}
, . , UTF-8 (, UTF-8), , UTF-8 wchar_t
<codecvt>
<locale>
, Windows , . - mbstowcs()
. STL, . , , , , UTF-8.
-, , UTF-8 API, Windows, - UTF-16, API. UTF-8 , , . , , UTF-8 , , wchar_t
- UCS-32. , , .