20void strecpy(std::span<char> dst, std::string_view src);
31 return std::move(str);
34bool strtolower(std::string &str, std::string::size_type offs = 0);
36[[nodiscard]]
bool StrValid(std::span<const char> str);
38[[nodiscard]] std::string_view StrTrimView(std::string_view str, std::string_view characters_to_trim);
46[[nodiscard]]
int StrNaturalCompare(std::string_view s1, std::string_view s2,
bool ignore_garbage_at_front =
false);
54 bool operator()(std::string_view s1, std::string_view s2)
const {
return StrCompareIgnoreCase(s1, s2) < 0; }
68 return c >= 0xD800 && c <= 0xDBFF;
78 return c >= 0xDC00 && c <= 0xDFFF;
89 return 0x10000 + (((lead - 0xD800) << 10) | (trail - 0xDC00));
129inline bool IsPrintable(
char32_t c)
131 if (c < 0x20)
return false;
132 if (c < 0xE000)
return true;
133 if (c < 0xE200)
return false;
146 return c == 0x0020 || c == 0x3000;
150#if defined(__NetBSD__) || defined(__FreeBSD__)
151#include <sys/param.h>
154std::optional<std::string_view>
GetEnv(
const char *variable);
Functions related to bit mathematics.
fluid_settings_t * settings
FluidSynth settings handle.
bool ConvertHexToBytes(std::string_view hex, std::span< uint8_t > bytes)
Convert a hex-string to a byte-array, while validating it was actually hex.
bool StrNaturalContainsIgnoreCase(std::string_view str, std::string_view value)
Checks if a string is contained in another string with a locale-aware comparison that is case insensi...
char32_t Utf16DecodeSurrogate(uint lead, uint trail)
Convert an UTF-16 surrogate pair to the corresponding Unicode character.
size_t Utf8StringLength(std::string_view str)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
char32_t Utf16DecodeChar(const uint16_t *c)
Decode an UTF-16 character.
bool Utf16IsLeadSurrogate(uint c)
Is the given character a lead surrogate code point?
bool StrNaturalContains(std::string_view str, std::string_view value)
Checks if a string is contained in another string with a locale-aware comparison that is case sensiti...
bool IsValidChar(char32_t key, CharSetFilter afilter)
Only allow certain keys.
std::optional< std::string_view > GetEnv(const char *variable)
Get the environment variable using std::getenv and when it is an empty string (or nullptr),...
bool IsWhitespace(char32_t c)
Check whether UNICODE character is whitespace or not, i.e.
void strecpy(std::span< char > dst, std::string_view src)
Copies characters from one buffer to another.
std::string FormatArrayAsHex(std::span< const uint8_t > data)
Format a byte array into a continuous hex string.
bool StrEqualsIgnoreCase(std::string_view str1, std::string_view str2)
Compares two string( view)s for equality, while ignoring the case of the characters.
bool StrEndsWithIgnoreCase(std::string_view str, std::string_view suffix)
Check whether the given string ends with the given suffix, ignoring case.
bool StrValid(std::span< const char > str)
Checks whether the given string is valid, i.e.
void StrMakeValidInPlace(char *str, StringValidationSettings settings=StringValidationSetting::ReplaceWithQuestionMark)
Scans the string for invalid characters and replaces them with a question mark '?' (if not ignored).
bool Utf16IsTrailSurrogate(uint c)
Is the given character a lead surrogate code point?
bool IsTextDirectionChar(char32_t c)
Is the given character a text direction character.
void StrTrimInPlace(std::string &str)
Trim the spaces from given string in place, i.e.
bool StrStartsWithIgnoreCase(std::string_view str, std::string_view prefix)
Check whether the given string starts with the given prefix, ignoring case.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front=false)
Compares two strings using case insensitive natural sort.
int StrCompareIgnoreCase(std::string_view str1, std::string_view str2)
Compares two string( view)s, while ignoring the case of the characters.
bool StrContainsIgnoreCase(std::string_view str, std::string_view value)
Checks if a string is contained in another string, while ignoring the case of the characters.
std::string StrMakeValid(std::string_view str, StringValidationSettings settings=StringValidationSetting::ReplaceWithQuestionMark)
Copies the valid (UTF-8) characters from str to the returned string.
@ ReplaceWithQuestionMark
Replace the unknown/bad bits with question marks.
static const char32_t CHAR_TD_RLE
The following text is embedded right-to-left.
static const char32_t CHAR_TD_LRO
Force the following characters to be treated as left-to-right characters.
static const char32_t CHAR_TD_LRM
The next character acts like a left-to-right character.
CharSetFilter
Valid filter types for IsValidChar.
static const char32_t CHAR_TD_RLO
Force the following characters to be treated as right-to-left characters.
static const char32_t CHAR_TD_LRE
The following text is embedded left-to-right.
static const char32_t CHAR_TD_RLM
The next character acts like a right-to-left character.
static const char32_t CHAR_TD_PDF
Restore the text-direction state to before the last LRE, RLE, LRO or RLO.
Case insensitive comparator for strings, for example for use in std::map.