Table of Contents

C - C++ Strings - Convert wstring to string

wstring_to_string.hpp

#pragma once
 
#include <string>
 
std::string to_string(std::wstring str);

wstring_to_string.cpp

#include "wstring_to_string.hpp"
 
std::string to_string(std::wstring str)
{
  return std::string(str.begin(), str.end());
}

References

https://en.cppreference.com/w/cpp/string/basic_string/basic_string