Boost logo

Boost :

From: Takeshi Mouri (takeshi.mouri.net_at_[hidden])
Date: 2006-03-01 10:31:35

Hi Beman,

> > I tested directory_iterator and fstream for Chinese file names
> > on Windows XP Japanese edition.
> > directory_iterator worked correctly, but fstream didn't.
> Thanks Takeshi. I'll give your patch a try tomorrow.
> Do you have a test case you would like to see added to the regression test?

Woops! I had forgotten to write the test case.
I tested this by VC7.1 and VC8.

#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/test/unit_test.hpp>
#include <locale>

// Japanese Hello
const wchar_t hello_jp[] = L"\u3053\u3093\u306B\u3061\u306F.txt";
// Chinese Hello
const wchar_t hello_cn[] = L"\u4F60\u597D.txt";

namespace fs = boost::filesystem;
namespace ut = boost::unit_test;

void test_unicode_path_fstream_aux(const fs::wpath& ph)

    // open and write 3 bytes
    fs::ofstream os(ph);
    os << "abc" << std::flush;

    // check by "true" Unicode function
    BOOST_CHECK_EQUAL(fs::file_size(ph), 3);


void test_unicode_path_fstream()
    // Dinkumware's fstream requires this for non-ASCII filename


ut::test_suite* init_unit_test_suite(int, char* [])
    ut::test_suite* test = BOOST_TEST_SUITE("test wpath fstream");
    return test;

Takeshi Mouri

Boost list run by bdawes at, gregod at, cpdaniel at, john at