wide string: To{W,}String: provide overload for rvalue references
This commit is contained in:
@@ -18,21 +18,9 @@
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string> // include before boost to compile on MACOSX
|
||||
#include <boost/locale/encoding_utf.hpp>
|
||||
#include <cassert>
|
||||
#include "utility/wide_string.h"
|
||||
|
||||
std::string ToString(const std::wstring &ws)
|
||||
{
|
||||
return boost::locale::conv::utf_to_utf<char>(ws);
|
||||
}
|
||||
|
||||
std::wstring ToWString(const std::string &s)
|
||||
{
|
||||
return boost::locale::conv::utf_to_utf<wchar_t>(s);
|
||||
}
|
||||
|
||||
size_t wideLength(const std::wstring &ws)
|
||||
{
|
||||
size_t result = 0;
|
||||
|
||||
@@ -21,10 +21,19 @@
|
||||
#ifndef NCMPCPP_UTILITY_WIDE_STRING_H
|
||||
#define NCMPCPP_UTILITY_WIDE_STRING_H
|
||||
|
||||
#include <string>
|
||||
#include <string> // include before boost to compile on MACOSX
|
||||
#include <boost/locale/encoding_utf.hpp>
|
||||
|
||||
std::string ToString(const std::wstring &ws);
|
||||
std::wstring ToWString(const std::string &s);
|
||||
template <typename StringT>
|
||||
std::string ToString(StringT &&s)
|
||||
{
|
||||
return boost::locale::conv::utf_to_utf<char>(std::forward<StringT>(s));
|
||||
}
|
||||
template <typename StringT>
|
||||
std::wstring ToWString(StringT &&s)
|
||||
{
|
||||
return boost::locale::conv::utf_to_utf<wchar_t>(std::forward<StringT>(s));
|
||||
}
|
||||
|
||||
size_t wideLength(const std::wstring &ws);
|
||||
void wideCut(std::wstring &ws, size_t max_length);
|
||||
|
||||
Reference in New Issue
Block a user