Flutter Engine
wstring_conversion.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_FML_PLATFORM_WIN_WSTRING_CONVERSION_H_
6 #define FLUTTER_FML_PLATFORM_WIN_WSTRING_CONVERSION_H_
7 
8 #include <codecvt>
9 #include <locale>
10 #include <string>
11 
12 namespace fml {
13 
14 using WideStringConvertor =
15  std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>;
16 
17 inline std::wstring StringToWideString(const std::string& str) {
18  WideStringConvertor converter;
19  return converter.from_bytes(str);
20 }
21 
22 inline std::string WideStringToString(const std::wstring& wstr) {
23  WideStringConvertor converter;
24  return converter.to_bytes(wstr);
25 }
26 
27 } // namespace fml
28 
29 #endif // FLUTTER_FML_PLATFORM_WIN_WSTRING_CONVERSION_H_
Definition: ascii_trie.cc:9
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t >, wchar_t > WideStringConvertor
std::wstring StringToWideString(const std::string &str)
std::string WideStringToString(const std::wstring &wstr)