diff options
| author | 2018-06-06 16:38:54 +0300 | |
|---|---|---|
| committer | 2018-06-07 09:59:47 +0300 | |
| commit | a2efb1dd48cd2242ac9c435787915c1154266d60 (patch) | |
| tree | cddeb32b5d74a6fb9f06bb994021413ebd197ae6 /src/common/string_util.cpp | |
| parent | Merge pull request #522 from mailwl/mm-u (diff) | |
| download | yuzu-a2efb1dd48cd2242ac9c435787915c1154266d60.tar.gz yuzu-a2efb1dd48cd2242ac9c435787915c1154266d60.tar.xz yuzu-a2efb1dd48cd2242ac9c435787915c1154266d60.zip | |
Common/string_util: add StringFromBuffer function
convert input buffer (std::vector<u8>) to string, stripping zero chars
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 1d952874d..646400db0 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 | |||
| 64 | return oss.str(); | 64 | return oss.str(); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | std::string StringFromBuffer(const std::vector<u8>& data) { | ||
| 68 | return std::string(data.begin(), std::find(data.begin(), data.end(), '\0')); | ||
| 69 | } | ||
| 70 | |||
| 67 | // Turns " hej " into "hej". Also handles tabs. | 71 | // Turns " hej " into "hej". Also handles tabs. |
| 68 | std::string StripSpaces(const std::string& str) { | 72 | std::string StripSpaces(const std::string& str) { |
| 69 | const size_t s = str.find_first_not_of(" \t\r\n"); | 73 | const size_t s = str.find_first_not_of(" \t\r\n"); |