Audacity 3.2.0
CodeConversions.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file CodeConversions.cpp
6 @brief Define functions to perform UTF-8 to std::wstring conversions.
7
8 Dmitry Vedenko
9 **********************************************************************/
10
11#include "CodeConversions.h"
12
13#include <locale>
14#include <codecvt>
15
16namespace audacity
17{
18
19std::string ToUTF8 (const std::wstring& wstr)
20{
21 return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
22}
23
24std::string ToUTF8 (const wchar_t* wstr)
25{
26 return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
27}
28
29std::string ToUTF8 (const wxString& wstr)
30{
31 return wstr.ToStdString (wxGet_wxConvUTF8 ());
32}
33
34std::wstring ToWString (const std::string& str)
35{
36 return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
37}
38
39std::wstring ToWString (const char* str)
40{
41 return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
42}
43
44std::wstring ToWString (const wxString& str)
45{
46 return str.ToStdWstring ();
47}
48
49wxString ToWXString (const std::string& str)
50{
51 return wxString::FromUTF8 (str);
52}
53
54wxString ToWXString (const std::wstring& str)
55{
56 return wxString (str);
57}
58
59}
Declare functions to perform UTF-8 to std::wstring conversions.
#define str(a)
std::string ToUTF8(const std::wstring &wstr)
std::wstring ToWString(const std::string &str)
wxString ToWXString(const std::string &str)