C++/WinRT nasty gotcha: winrt::param::hstring constructed from std::wstring_view requires null termination

4 · Raymond Chen · Aug. 23, 2021, 2:01 p.m.
The std::string_view (and wide buddy std::wstring_view) represent a contiguous sequence of characters, not necessarily null-terminated. One nasty gotcha in C++/WinRT is that if you try to construct a winrt::hstring from a std::wstring_view, the C++/WinRT library requires that your std::wstring_view be followed with a null terminator. The post C++/WinRT nasty gotcha: <CODE>winrt::param::hstring</CODE> constructed from <CODE>std::wstring_view</CODE> requires null termination appeared first on The...