diff --git a/src/xenia/base/utf8.cc b/src/xenia/base/utf8.cc index 22d78f9cf..88abe3b6c 100644 --- a/src/xenia/base/utf8.cc +++ b/src/xenia/base/utf8.cc @@ -159,7 +159,8 @@ inline utf8_citer find_needle_case(utf8_citer haystack_it, } std::vector split(const std::string_view haystack, - const std::string_view needles) { + const std::string_view needles, + bool remove_empty) { std::vector result; auto [haystack_begin, haystack_end] = make_citer(haystack); @@ -177,6 +178,8 @@ std::vector split(const std::string_view haystack, auto offset = byte_length(haystack_begin, last); auto length = byte_length(haystack_begin, it) - offset; result.push_back(haystack.substr(offset, length)); + } else if (!remove_empty) { + result.push_back(""); } ++it; @@ -478,7 +481,7 @@ bool ends_with_case(const std::string_view haystack, } std::vector split_path(const std::string_view path) { - return split(path, u8"\\/"); + return split(path, u8"\\/", true); } std::string join_paths(const std::string_view left_path, diff --git a/src/xenia/base/utf8.h b/src/xenia/base/utf8.h index 73094ccbf..bfdf99b87 100644 --- a/src/xenia/base/utf8.h +++ b/src/xenia/base/utf8.h @@ -27,7 +27,8 @@ size_t hash_fnv1a_case(const std::string_view view); // Splits the given string on any delimiters and returns all parts. std::vector split(const std::string_view path, - const std::string_view delimiters); + const std::string_view delimiters, + bool remove_empty = false); bool equal_z(const std::string_view left, const std::string_view right);