diff options
| author | bunnei <bunneidev@gmail.com> | 2018-06-08 18:51:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-08 18:51:00 -0400 |
| commit | 7ff5d3ef92e77259c24b2259c2c8e43c15ce30f4 (patch) | |
| tree | 390ca18637ba51f2f5709a2bd01fb6ef55b6fdcc /src/common/string_util.cpp | |
| parent | 4b2df1fe484e23124fc6ecd84130f4797e93c296 (diff) | |
| parent | b70838ca6037da8856373909a175d43c562522e8 (diff) | |
Merge pull request #533 from mailwl/array-to-buffer
Common/string_util: add StringFromBuffer() function
Diffstat (limited to 'src/common/string_util.cpp')
| -rw-r--r-- | src/common/string_util.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 1d952874d2..646400db0e 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -64,6 +64,10 @@ std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces return oss.str(); } +std::string StringFromBuffer(const std::vector<u8>& data) { + return std::string(data.begin(), std::find(data.begin(), data.end(), '\0')); +} + // Turns " hej " into "hej". Also handles tabs. std::string StripSpaces(const std::string& str) { const size_t s = str.find_first_not_of(" \t\r\n"); |
