// https://www.boost.org/doc/libs/1_92_0/libs/nowide/doc/html/index.html

#include <boost/nowide/convert.hpp>
#include <boost/nowide/cstdio.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/nowide/utf8_codecvt.hpp>

#include <cassert>
#include <iostream>
#include <string>

int main()
{
    const char *name = "nowide-Grüße.txt";
    const std::string payload = "Zwölf laufende Bäche";

    {
        boost::nowide::ofstream out(name);
        assert(out);
        out << payload << std::endl;
    }

    std::string line;
    {
        boost::nowide::ifstream in(name);
        assert(in);
        std::getline(in, line);
    }

    std::cout << "read back: " << line << std::endl;
    assert(line == payload);

    // Wide/narrow conversion helpers
    const std::wstring wide = boost::nowide::widen(payload);
    assert(boost::nowide::narrow(wide) == payload);

    assert(boost::nowide::remove(name) == 0);

    return 0;
}
