Flutter Engine
The Flutter Engine
fml
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.
18
std::locale::id
std::codecvt<char16_t, char, _Mbstatet>::id
;
19
#endif
// defined(FML_OS_WIN)
20
21
namespace
fml
{
22
23
using
Utf16StringConverter
=
24
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
char16_t
>;
25
26
std::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
37
std::string
Utf16ToUtf8
(
const
std::u16string_view
string
) {
38
Utf16StringConverter
converter
;
39
return
converter
.to_bytes(
string
.
data
());
40
}
41
42
std::u16string
Utf8ToUtf16
(
const
std::string_view
string
) {
43
Utf16StringConverter
converter
;
44
return
converter
.from_bytes(
string
.
data
());
45
}
46
47
}
// namespace fml
i
int i
Definition:
fl_socket_accessible.cc:18
cacheimages.converter
string converter
Definition:
cacheimages.py:19
fml
Definition:
ascii_trie.cc:9
fml::Utf16ToUtf8
std::string Utf16ToUtf8(const std::u16string_view string)
Definition:
string_conversion.cc:37
fml::Utf16StringConverter
std::wstring_convert< std::codecvt_utf8_utf16< char16_t >, char16_t > Utf16StringConverter
Definition:
string_conversion.cc:24
fml::Utf8ToUtf16
std::u16string Utf8ToUtf16(const std::string_view string)
Definition:
string_conversion.cc:42
fml::Join
std::string Join(const std::vector< std::string > &vec, const char *delim)
Definition:
string_conversion.cc:26
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
id
const uintptr_t id
Definition:
texture_unittests.cc:27
Generated on Sun Jun 23 2024 21:54:58 for Flutter Engine by
1.9.4