14#include "flutter/fml/string_conversion.h"
15#include "third_party/dart/third_party/double-conversion/src/double-conversion.h"
31constexpr int kDecimalInShortestLow = -6;
34constexpr int kDecimalInShortestHigh = 12;
35constexpr int kConversionFlags =
38const DoubleToStringConverter& GetDoubleToStringConverter() {
41 kDecimalInShortestLow, kDecimalInShortestHigh, 0, 0);
45std::string NumberToStringImpl(
double number,
bool is_single_precision) {
51 std::array<char, kBufferSize> char_buffer;
52 StringBuilder
builder(char_buffer.data(), char_buffer.size());
53 if (is_single_precision) {
54 GetDoubleToStringConverter().ToShortestSingle(
static_cast<float>(number),
57 GetDoubleToStringConverter().ToShortest(number, &
builder);
59 return std::string(char_buffer.data(),
builder.position());
64 return std::u16string(
src.begin(),
src.end());
100 return NumberToStringImpl(number,
true);
104 return NumberToStringImpl(number,
false);
108 std::ostringstream imploded;
109 for (
size_t i = 0;
i <
tokens.size();
i++) {
113 imploded <<
tokens[
i] << delimiter;
116 return imploded.str();
120 std::u16string delimiter) {
122 for (
size_t i = 0;
i <
tokens.size();
i++) {
137 size_t pos = in.find(from);
138 while (
pos != std::string::npos) {
139 in.replace(
pos, from.size(), to);
140 pos = in.find(from,
pos + to.size());
148 std::u16string*
out) {
149 size_t pos = in.find(from);
150 while (
pos != std::u16string::npos) {
151 in.replace(
pos, from.size(), to);
152 pos = in.find(from,
pos + to.size());
164 ret.reserve(str.size());
165 for (
size_t i = 0;
i < str.size();
i++)
166 ret.push_back(std::toupper(str[
i]));
172 ret.reserve(str.size());
173 for (
size_t i = 0;
i < str.size();
i++)
174 ret.push_back(std::tolower(str[
i]));
184 return std::find_if(str.begin(), str.end(),
185 [ch](
char16_t c) { return c != ch; }) == str.end();
static const size_t kBufferSize
@ EMIT_POSITIVE_EXPONENT_SIGN
std::string ToUpperASCII(std::string str)
std::string UTF16ToUTF8(std::u16string src)
void ReplaceChars(std::string in, std::string from, std::string to, std::string *out)
const std::string & EmptyString()
std::u16string UTF8ToUTF16(std::string src)
bool ContainsOnlyChars(std::u16string str, char16_t ch)
std::u16string ASCIIToUTF16(std::string src)
std::string ToLowerASCII(std::string str)
std::string JoinString(std::vector< std::string > tokens, std::string delimiter)
bool LowerCaseEqualsASCII(std::string a, std::string b)
std::string NumberToString(int32_t number)
std::u16string NumberToString16(float number)
static constexpr const char * kInfinitySymbol
static constexpr const char * kNaNSymbol
static constexpr char kExponentChar
std::string Utf16ToUtf8(const std::u16string_view string)
std::u16string Utf8ToUtf16(const std::string_view string)
static SkString to_string(int n)