winrt::to_string function (C++/WinRT)

A helper function that converts an input wide string to a std::string containing a UTF-8 narrow string by calling WideCharToMultiByte. For more info, and a code example, see winrt::hstring functions and operators.

Syntax

inline std::string to_string(std::wstring_view value);

Parameters

value A std::wstring_view value, or any value of a type convertible to std::wstring_view, to convert into a UTF-8 narrow string. This can be a winrt::hstring, thanks to hstring's conversion operator to std::wstring_view.

Return value

A std::string containing a UTF-8 narrow string resulting from converting the parameter.

Requirements

Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

Namespace: winrt

Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

See also