How to portably write std::wstring to file?
问题 I have a wstring declared as such: // random wstring std::wstring str = L"abcàdëefŸg€hhhhhhhµa"; The literal would be UTF-8 encoded, because my source file is. [EDIT: According to Mark Ransom this is not necessarily the case, the compiler will decide what encoding to use - let us instead assume that I read this string from a file encoded in e.g. UTF-8] I would very much like to get this into a file reading (when text editor is set to the correct encoding) abcàdëefŸg€hhhhhhhµa but ofstream is