Reading and writing a Unicode file in C++

In one of my recent project I had to read and write a CSV file having JAPANESE strings.Here I will explain how we can read and write a Unicode file in c++.
std::wstring readUnicodeFile(const char* filename)
    std::ifstream wif(filename);
    std::stringstream wss;
    wss << wif.rdbuf();
    std::string  const &str = wss.str();
    std::wstring wstr;
    std::memcpy(&wstr[0],str.c_str(),str.size()); // copy data into wstring
    return wstr;
void WriteUnicodetoFile(const char* myFile,  wstring& ws){
    std::ofstream outFile(myFile, std::ios::out | std::ios::binary);
    outFile.write((char *) ws.c_str(), ws.length() * sizeof(wchar_t));
int main(int argc, _TCHAR* argv[])
    wstring sText = readUnicodeFile("inputUnicode.txt");
    WriteUnicodetoFile("ouputUnicode.txt",  sText);