std::wstring support
Hi,
I'm using this lib in an app to parse input files (between other things), but I'm having issues if the given file contains unicode characters.
Is there any way to use std::wstring instead (or in parallel to) std::strings?
I have to admit I dont have much experience with std::wstring. All my work in unicode is with UTF8 and std::string works well there, so I've never had to reach for anything else. (Not saying they're not valuable, just personal experience).
Back with some more.
Did you do your tests on windows or linux?
Cause on windows, I can't seem to get anything decent with the classic main(int argc, char* argv[]), I have to use a special version that gives me a wchar_t*[] as argv.
And if I try to convert it back into regular std::string, it crashes as soon as the string is read.
edit:
Found a hack to make it work:
using convert_type = std::codecvt_utf8<wchar_t>; std::wstring_convert<convert_type, wchar_t> converter; std::vector<std::string> strs(argc - 1); std::transform(argv + 1, argv + argc, begin(strs), [&converter](wchar_t* wstr) { return converter.to_bytes(wstr); }); const auto args = docopt::docopt(USAGE, arguments, true,"v1.0");
We have Travis set up to test both Linux and OSX (it does not support Windows). I have had pull-requests from Windows users to make the library work better with MSVC so it should work.