Created
April 5, 2014 19:30
-
-
Save stevenRush/9996882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <exception> | |
#include <codecvt> | |
#include <streambuf> | |
#include <string> | |
#include <cerrno> | |
#include <sstream> | |
using namespace std; | |
int main() | |
{ | |
// Setup C++ rtl global default locale | |
std::locale r1251("Russian_Russia.1251"); | |
std::locale utf8(std::locale(), new std::codecvt_utf8<wchar_t>); | |
std::locale utf16(std::locale(), new std::codecvt_utf16<wchar_t>); | |
std::locale::global(r1251); | |
// Setup locales for wide streams | |
std::wcout.imbue(r1251); | |
// For correct io with wcin/wcout disconnect stream from wstream | |
std::ios::sync_with_stdio(false); | |
wstring str; | |
wifstream in1251("C:\\temp\\input_1251.txt"); | |
in1251.imbue(r1251); | |
getline(in1251, str); | |
wcout << str << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment