diff options
| author | Mat M <mathew1800@gmail.com> | 2021-05-13 06:47:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-13 06:47:38 -0400 |
| commit | 7a72a5b997f87bcb7f55c9fbd358328fec68e536 (patch) | |
| tree | 92032c7cdc1a60fd3c3d6390ebd87f477ee37183 /Source/Core/Common/StringUtil.cpp | |
| parent | d034c830acfab16f93aefcfe65e3719f3f87cb4a (diff) | |
| parent | 574477866fe3e82a87214848d3d4b505535f2d3b (diff) | |
Merge pull request #9703 from Filoppi/fix_expression_serialization
Fix serialization of control expressions with line breaks
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index ffda64c79f..9c57bf944a 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -219,7 +219,7 @@ std::string ArrayToString(const u8* data, u32 size, int line_len, bool spaces) return oss.str(); } -// Turns " hello " into "hello". Also handles tabs. +// Turns "\n\r\t hello " into "hello" (trims at the start and end but not inside). std::string_view StripSpaces(std::string_view str) { const size_t s = str.find_first_not_of(" \t\r\n"); @@ -241,6 +241,13 @@ std::string_view StripQuotes(std::string_view s) return s; } +// Turns "\n\rhello" into " hello". +void ReplaceBreaksWithSpaces(std::string& str) +{ + std::replace(str.begin(), str.end(), '\r', ' '); + std::replace(str.begin(), str.end(), '\n', ' '); +} + bool TryParse(const std::string& str, bool* const output) { float value; |
