diff options
| author | levlam <levlam@telegram.org> | 2025-07-06 05:55:48 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-07-06 05:55:48 +0300 |
| commit | 43192229ade978f4b251c5e740f8ba6a64dbd052 (patch) | |
| tree | 82fc432e9c9dce407a6833e3e7c0aa8af975903b /tdutils | |
| parent | 6c8bfbb520fc0d33d0e865736c80ee9a0e5b46c0 (diff) | |
Add and use replace_with_spaces.
Diffstat (limited to 'tdutils')
| -rw-r--r-- | tdutils/td/utils/misc.cpp | 8 | ||||
| -rw-r--r-- | tdutils/td/utils/misc.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tdutils/td/utils/misc.cpp b/tdutils/td/utils/misc.cpp index 4d3050c60..7eab34f60 100644 --- a/tdutils/td/utils/misc.cpp +++ b/tdutils/td/utils/misc.cpp @@ -18,6 +18,14 @@ namespace td { +void replace_with_spaces(MutableSlice str, Slice characters) { + for (auto &c : str) { + if (characters.find(c) != Slice::npos) { + c = ' '; + } + } +} + char *str_dup(Slice str) { auto *res = static_cast<char *>(std::malloc(str.size() + 1)); if (res == nullptr) { diff --git a/tdutils/td/utils/misc.h b/tdutils/td/utils/misc.h index 824d75461..9b2815ab5 100644 --- a/tdutils/td/utils/misc.h +++ b/tdutils/td/utils/misc.h @@ -102,6 +102,8 @@ inline string to_upper(Slice slice) { return result; } +void replace_with_spaces(MutableSlice str, Slice characters); + inline bool is_space(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\0' || c == '\v'; } |
