Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWT should support wide strings in BOOST_TEST_EQ #87

Open
pdimov opened this issue Mar 10, 2021 · 2 comments
Open

LWT should support wide strings in BOOST_TEST_EQ #87

pdimov opened this issue Mar 10, 2021 · 2 comments

Comments

@pdimov
Copy link
Member

pdimov commented Mar 10, 2021

Outputting wide strings to std::cout outputs the void* under C++ before 20, and hits a deleted op<< in C++20. We should make it work, either by transcoding to UTF-8, or by using the codecvt facet of the output stream.

This might entail adding an adapter such as boost::core::narrow(x) that is similar to quoted(x) in that when output to a stream, it does the necessary narrowing using codecvt. (We can't add it to io because Core is not allowed to depend on Io.)

Related: we don't have a wide equivalent of BOOST_TEST_CSTR_EQ.

@Lastique
Copy link
Member

We should make it work, either by transcoding to UTF-8, or by using the codecvt facet of the output stream.

I have something like this in Boost.Log:

https://github.com/boostorg/log/blob/8a880720be5a990fdd0f864244bfff1a39a69d83/include/boost/log/utility/formatting_ostream.hpp#L398-L416
https://github.com/boostorg/log/blob/8a880720be5a990fdd0f864244bfff1a39a69d83/src/code_conversion.cpp#L68-L139

I'm not sure we want that particular solution, instead of just outputting to std::wcout.

@Lastique
Copy link
Member

We can't add it to io because Core is not allowed to depend on Io.

I don't like that we're adding stuff to Core just because we don't want to add it to the module where it really belongs. Code reuse must work, however modular we want to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants