chromium/base/strings/string_util.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/strings/string_util.h"

#include <errno.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>

#include <limits>
#include <optional>
#include <string_view>
#include <type_traits>
#include <vector>

#include "base/check_op.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util_impl_helpers.h"
#include "base/strings/string_util_internal.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "base/third_party/icu/icu_utf.h"
#include "build/build_config.h"

namespace base {

bool IsWprintfFormatPortable(const wchar_t* format) {}

std::string ToLowerASCII(std::string_view str) {}

std::u16string ToLowerASCII(std::u16string_view str) {}

std::string ToUpperASCII(std::string_view str) {}

std::u16string ToUpperASCII(std::u16string_view str) {}

const std::string& EmptyString() {}

const std::u16string& EmptyString16() {}

bool ReplaceChars(std::u16string_view input,
                  std::u16string_view replace_chars,
                  std::u16string_view replace_with,
                  std::u16string* output) {}

bool ReplaceChars(std::string_view input,
                  std::string_view replace_chars,
                  std::string_view replace_with,
                  std::string* output) {}

bool RemoveChars(std::u16string_view input,
                 std::u16string_view remove_chars,
                 std::u16string* output) {}

bool RemoveChars(std::string_view input,
                 std::string_view remove_chars,
                 std::string* output) {}

bool TrimString(std::u16string_view input,
                std::u16string_view trim_chars,
                std::u16string* output) {}

bool TrimString(std::string_view input,
                std::string_view trim_chars,
                std::string* output) {}

std::u16string_view TrimString(std::u16string_view input,
                               std::u16string_view trim_chars,
                               TrimPositions positions) {}

std::string_view TrimString(std::string_view input,
                            std::string_view trim_chars,
                            TrimPositions positions) {}

void TruncateUTF8ToByteSize(const std::string& input,
                            const size_t byte_size,
                            std::string* output) {}

TrimPositions TrimWhitespace(std::u16string_view input,
                             TrimPositions positions,
                             std::u16string* output) {}

std::u16string_view TrimWhitespace(std::u16string_view input,
                                   TrimPositions positions) {}

TrimPositions TrimWhitespaceASCII(std::string_view input,
                                  TrimPositions positions,
                                  std::string* output) {}

std::string_view TrimWhitespaceASCII(std::string_view input,
                                     TrimPositions positions) {}

std::u16string CollapseWhitespace(std::u16string_view text,
                                  bool trim_sequences_with_line_breaks) {}

std::string CollapseWhitespaceASCII(std::string_view text,
                                    bool trim_sequences_with_line_breaks) {}

bool ContainsOnlyChars(std::string_view input, std::string_view characters) {}

bool ContainsOnlyChars(std::u16string_view input,
                       std::u16string_view characters) {}

bool IsStringASCII(std::string_view str) {}

bool IsStringASCII(std::u16string_view str) {}

#if defined(WCHAR_T_IS_32_BIT)
bool IsStringASCII(std::wstring_view str) {}
#endif

bool IsStringUTF8(std::string_view str) {}

bool IsStringUTF8AllowingNoncharacters(std::string_view str) {}

bool EqualsASCII(std::u16string_view str, std::string_view ascii) {}

bool StartsWith(std::string_view str,
                std::string_view search_for,
                CompareCase case_sensitivity) {}

bool StartsWith(std::u16string_view str,
                std::u16string_view search_for,
                CompareCase case_sensitivity) {}

bool EndsWith(std::string_view str,
              std::string_view search_for,
              CompareCase case_sensitivity) {}

bool EndsWith(std::u16string_view str,
              std::u16string_view search_for,
              CompareCase case_sensitivity) {}

char HexDigitToInt(char c) {}

static const char* const kByteStringsUnlocalized[] =;

std::u16string FormatBytesUnlocalized(int64_t bytes) {}

void ReplaceFirstSubstringAfterOffset(std::u16string* str,
                                      size_t start_offset,
                                      std::u16string_view find_this,
                                      std::u16string_view replace_with) {}

void ReplaceFirstSubstringAfterOffset(std::string* str,
                                      size_t start_offset,
                                      std::string_view find_this,
                                      std::string_view replace_with) {}

void ReplaceSubstringsAfterOffset(std::u16string* str,
                                  size_t start_offset,
                                  std::u16string_view find_this,
                                  std::u16string_view replace_with) {}

void ReplaceSubstringsAfterOffset(std::string* str,
                                  size_t start_offset,
                                  std::string_view find_this,
                                  std::string_view replace_with) {}

char* WriteInto(std::string* str, size_t length_with_null) {}

char16_t* WriteInto(std::u16string* str, size_t length_with_null) {}

std::string JoinString(span<const std::string> parts,
                       std::string_view separator) {}

std::u16string JoinString(span<const std::u16string> parts,
                          std::u16string_view separator) {}

std::string JoinString(span<const std::string_view> parts,
                       std::string_view separator) {}

std::u16string JoinString(span<const std::u16string_view> parts,
                          std::u16string_view separator) {}

std::string JoinString(std::initializer_list<std::string_view> parts,
                       std::string_view separator) {}

std::u16string JoinString(std::initializer_list<std::u16string_view> parts,
                          std::u16string_view separator) {}

std::u16string ReplaceStringPlaceholders(
    std::u16string_view format_string,
    const std::vector<std::u16string>& subst,
    std::vector<size_t>* offsets) {}

std::string ReplaceStringPlaceholders(std::string_view format_string,
                                      const std::vector<std::string>& subst,
                                      std::vector<size_t>* offsets) {}

std::u16string ReplaceStringPlaceholders(const std::u16string& format_string,
                                         const std::u16string& a,
                                         size_t* offset) {}

size_t strlcpy(char* dst, const char* src, size_t dst_size) {}

size_t u16cstrlcpy(char16_t* dst, const char16_t* src, size_t dst_size) {}

size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) {}

}  // namespace base