Flutter Engine
The Flutter Engine
string_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/string_conversion.h"
6
7#include <codecvt>
8#include <locale>
9#include <sstream>
10#include <string>
11
12#include "flutter/fml/build_config.h"
13
14#if defined(FML_OS_WIN)
15// TODO(naifu): https://github.com/flutter/flutter/issues/98074
16// Eliminate this workaround for a link error on Windows when the underlying
17// bug is fixed.
19#endif // defined(FML_OS_WIN)
20
21namespace fml {
22
24 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>;
25
26std::string Join(const std::vector<std::string>& vec, const char* delim) {
27 std::stringstream res;
28 for (size_t i = 0; i < vec.size(); ++i) {
29 res << vec[i];
30 if (i < vec.size() - 1) {
31 res << delim;
32 }
33 }
34 return res.str();
35}
36
37std::string Utf16ToUtf8(const std::u16string_view string) {
39 return converter.to_bytes(string.data());
40}
41
42std::u16string Utf8ToUtf16(const std::string_view string) {
44 return converter.from_bytes(string.data());
45}
46
47} // namespace fml
string converter
Definition: cacheimages.py:19
Definition: ascii_trie.cc:9
std::string Utf16ToUtf8(const std::u16string_view string)
std::wstring_convert< std::codecvt_utf8_utf16< char16_t >, char16_t > Utf16StringConverter
std::u16string Utf8ToUtf16(const std::string_view string)
std::string Join(const std::vector< std::string > &vec, const char *delim)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
const uintptr_t id