Opened 13 years ago

Closed 12 years ago

#3088 closed Feature Requests (wontfix)

Support of std::wstring versions of boost::iostreams::basic_file::open()

Reported by: anonymous Owned by: Jonathan Turkanis
Milestone: Boost 1.40.0 Component: iostreams
Version: Boost 1.39.0 Severity: Optimization
Keywords: Cc:

Description

It would be quite usefull to have support for files with unicode filenames. i.e.

boost::iostreams::file f( L"Japanese characters" );

Change History (3)

comment:1 by anonymous, 13 years ago

Agreed... On Windows with msvc 2008, we end up doing something like:

wchar_t wideFile = L"example.txt"; // file we want to open with boost
std::string  fileName;

// first call gets buffer size
int bufSize = ::WideCharToMultiByte(CP_ACP, 0, wideFile, -1, 
                                    NULL, 0, NULL, NULL);

fileName.resize (bufSize);

// second call converts the filename
int iRet = ::WideCharToMultiByte(CP_ACP, 0, wideFile, -1,
                                 &fileName.at(0), bufSize, NULL, NULL);

boost::iostreams::file_sink(fileName.c_str(), ...)

comment:2 by anonymous, 13 years ago

The code snipped anbove only works if all the characters in the filename are available in CP_ACP, which is not the case for most japanese characters in the usual 850 codepage. A native support of std::wstring would be much better if the implementation of the STL supports std::basic_fstream(const wchar_t *_Filename...)

comment:3 by Steven Watanabe, 12 years ago

Resolution: wontfix
Status: newclosed

Since file_sink relies on std::streambuf which doesn't support wide character open, this is not feasible. file_descriptor, however, does handle wide paths (via boost::filesystem::path).

Note: See TracTickets for help on using tickets.