The code is not working because the call 'file.is_open()' returns false. The thing is that this call is actually working with Chinese or Japanese characters, but these characters 'āōēāōēāōē' are causing a lot of trouble.
// Test239658.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h" // uncomment if it Visual Studio complains
#include <iostream>
#include <fstream>
bool openFile(std::wstring pathToCopy)
{
std::wofstream file(pathToCopy, std::wofstream::out | std::wofstream::binary);
return file.is_open();
}
int main()
{
if (openFile(L"C:/āōēāōēāōē/file.icc"))
{
std::cout << "success" << std::endl;
}
else
{
std::cout << "failure" << std::endl;
}
}
PS: Visual Studio encodes it in 16-bit windows-unicode, I think.
PPS: \\ (backslash) is almost never needed when opening files in C++, Windows will handle forward slashes just fine (/).