Audacity  3.0.3
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 preform UTF-8 to std::wstring conversions.
7 
8  Dmitry Vedenko
9  **********************************************************************/
10 
11 #include "CodeConversions.h"
12 
13 #include <locale>
14 #include <codecvt>
15 
16 namespace audacity
17 {
18 
19 std::string ToUTF8 (const std::wstring& wstr)
20 {
21  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
22 }
23 
24 std::string ToUTF8 (const wchar_t* wstr)
25 {
26  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
27 }
28 
29 std::string ToUTF8 (const wxString& wstr)
30 {
31  return wstr.ToStdString (wxGet_wxConvUTF8 ());
32 }
33 
34 std::wstring ToWString (const std::string& str)
35 {
36  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
37 }
38 
39 std::wstring ToWString (const char* str)
40 {
41  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
42 }
43 
44 std::wstring ToWString (const wxString& str)
45 {
46  return str.ToStdWstring ();
47 }
48 
49 wxString ToWXString (const std::string& str)
50 {
51  return wxString::FromUTF8 (str);
52 }
53 
54 wxString ToWXString (const std::wstring& str)
55 {
56  return wxString (str);
57 }
58 
59 }
audacity::ToWXString
wxString ToWXString(const std::string &str)
Definition: CodeConversions.cpp:49
audacity
Definition: ErrorReportDialog.h:22
audacity::ToWString
std::wstring ToWString(const std::string &str)
Definition: CodeConversions.cpp:34
CodeConversions.h
Declare functions to preform UTF-8 to std::wstring conversions.
audacity::ToUTF8
std::string ToUTF8(const std::wstring &wstr)
Definition: CodeConversions.cpp:19