Misc changes. #13
| @@ -140,6 +140,32 @@ namespace utils::string | ||||
| 		*out = '\0'; | ||||
| 	} | ||||
|  | ||||
| 	std::string strip(std::string_view sv, bool strip_default_color) | ||||
| 	{ | ||||
| 		std::string in(sv); | ||||
|  | ||||
| 		for (std::size_t i = 0; i + 1 < in.size();) | ||||
| 		{ | ||||
| 			if (in[i] == '^' && static_cast<std::size_t>(in[i + 1] - '0') < 0xC) | ||||
| 			{ | ||||
| 				if (in[i + 1] != '7' || strip_default_color) | ||||
| 				{ | ||||
| 					in.erase(in.begin() + i, in.begin() + i + 2); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					i += 2; | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				i += 1; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return in; | ||||
| 	} | ||||
|  | ||||
| 	std::string convert(const std::wstring& wstr) | ||||
| 	{ | ||||
| 		std::string result; | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| #pragma once | ||||
| #include "memory.hpp" | ||||
| #include <cstdint> | ||||
| #include <span> | ||||
|  | ||||
| template <class Type, size_t n> | ||||
| constexpr auto ARRAY_COUNT(Type(&)[n]) { return n; } | ||||
| @@ -91,6 +92,7 @@ namespace utils::string | ||||
| 	std::string get_clipboard_data(); | ||||
|  | ||||
| 	void strip(const char* in, char* out, size_t max); | ||||
| 	std::string strip(std::string_view sv, bool strip_default_color = false); | ||||
|  | ||||
| 	std::string convert(const std::wstring& wstr); | ||||
| 	std::wstring convert(const std::string& str); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user