summaryrefslogtreecommitdiff
path: root/src/common/fs/fs_util.h
diff options
context:
space:
mode:
authorGravatar Morph2021-06-01 09:19:08 -0400
committerGravatar Morph2021-06-02 00:26:26 -0400
commita1eeb9908d9cba0a51fbad519ce770b96d0a78d5 (patch)
tree937e4376d04b63b747d2e931b29b4ede31e9dbc5 /src/common/fs/fs_util.h
parentMerge pull request #6361 from lat9nq/per-hb-cfg (diff)
downloadyuzu-a1eeb9908d9cba0a51fbad519ce770b96d0a78d5.tar.gz
yuzu-a1eeb9908d9cba0a51fbad519ce770b96d0a78d5.tar.xz
yuzu-a1eeb9908d9cba0a51fbad519ce770b96d0a78d5.zip
common: fs: fs_util: Add more string conversion functions
Diffstat (limited to 'src/common/fs/fs_util.h')
-rw-r--r--src/common/fs/fs_util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/fs/fs_util.h b/src/common/fs/fs_util.h
index 951df53b6..de452c0f6 100644
--- a/src/common/fs/fs_util.h
+++ b/src/common/fs/fs_util.h
@@ -5,9 +5,12 @@
5#pragma once 5#pragma once
6 6
7#include <concepts> 7#include <concepts>
8#include <span>
8#include <string> 9#include <string>
9#include <string_view> 10#include <string_view>
10 11
12#include "common/common_types.h"
13
11namespace Common::FS { 14namespace Common::FS {
12 15
13template <typename T> 16template <typename T>
@@ -22,4 +25,24 @@ concept IsChar = std::same_as<T, char>;
22 */ 25 */
23[[nodiscard]] std::u8string ToU8String(std::string_view utf8_string); 26[[nodiscard]] std::u8string ToU8String(std::string_view utf8_string);
24 27
28/**
29 * Converts a buffer of bytes to a UTF8-encoded std::u8string.
30 * This converts from the start of the buffer until the first encountered null-terminator.
31 * If no null-terminator is found, this converts the entire buffer instead.
32 *
33 * @param buffer Buffer of bytes
34 *
35 * @returns UTF-8 encoded std::u8string.
36 */
37[[nodiscard]] std::u8string BufferToU8String(std::span<const u8> buffer);
38
39/**
40 * Converts a std::u8string or std::u8string_view to a UTF-8 encoded std::string.
41 *
42 * @param u8_string UTF-8 encoded u8string
43 *
44 * @returns UTF-8 encoded std::string.
45 */
46[[nodiscard]] std::string ToUTF8String(std::u8string_view u8_string);
47
25} // namespace Common::FS 48} // namespace Common::FS