Look here:
http://www.codeproject.com/KB/MFC/CryptoPPCFileMFC.aspx
It turns out that ifstream::open in MSVC 2005 and later can handle a Unicode
filename directly.
> On Linux you will have to convert you std::wstring into UTF8 encoded
> std::string first. (Using your favorite UTF8 conversion libraries :)).
wcstombs() can be used for this, and it seems to be a standard Unix
function.
I've checked in changes to enable FileSource, FileSink, and FileStore to
handle Unicode filenames on Unix and MSVC 2005 and later using the above
methods. Please take a look at
http://cryptopp.svn.sourceforge.net/viewvc/cryptopp?view=rev&revision=472 if
you'd like to review the code.
I was trying to keep the preexisting logic as much as possible to minimize
the possibility of introducing new errors. But you're right, the result is a
bit too convoluted. I've adopted your logic and improved it a bit (your code
doesn't compile as written). The new revision is at
http://cryptopp.svn.sourceforge.net/viewvc/cryptopp?view=rev&revision=473.