Flutter Engine
The Flutter Engine
wstring_conversion.cc
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#include "flutter/fml/platform/win/wstring_conversion.h"
6
7#include <codecvt>
8#include <locale>
9#include <string>
10
11namespace fml {
12
14 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>;
15
16std::string WideStringToUtf8(const std::wstring_view str) {
18 return converter.to_bytes(str.data());
19}
20
21std::wstring Utf8ToWideString(const std::string_view str) {
23 return converter.from_bytes(str.data());
24}
25
26std::u16string WideStringToUtf16(const std::wstring_view str) {
27 static_assert(sizeof(std::wstring::value_type) ==
28 sizeof(std::u16string::value_type));
29 return {begin(str), end(str)};
30}
31
32std::wstring Utf16ToWideString(const std::u16string_view str) {
33 static_assert(sizeof(std::wstring::value_type) ==
34 sizeof(std::u16string::value_type));
35 return {begin(str), end(str)};
36}
37
38} // namespace fml
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
glong glong end
string converter
Definition: cacheimages.py:19
Definition: ascii_trie.cc:9
std::wstring Utf8ToWideString(const std::string_view str)
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t >, wchar_t > WideStringConverter
std::string WideStringToUtf8(const std::wstring_view str)
std::u16string WideStringToUtf16(const std::wstring_view str)
std::wstring Utf16ToWideString(const std::u16string_view str)