
"Peter Dimov" <pdimov@mmltd.net> wrote in message news:00af01c6334a$b9ed2200$6407a8c0@pdimov2...
Recently, I needed to fix a program to work properly with paths that cannot be represented by narrow strings under Windows. The problematic filenames came from the user via drag and drop. I tried to go the wstring route, the same approach that the filesystem library takes; but it was harder than I thought. Many parts of the code base assumed narrow paths.
At the end I reverted the changes and just encoded the wide path into UTF-8 at the very start, passed the UTF-8 string through the existing code, then decoded the UTF-8 into a wstring at the very end, immediately before calling the Windows API. It worked.
Seems like a reasonable and practical approach. I've wondered several times if we wouldn't have been better off if Microsoft had chosen UTF-8 as their Window external representation, too. --Beman