-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxString.hpp
More file actions
30 lines (23 loc) · 821 Bytes
/
Copy pathxString.hpp
File metadata and controls
30 lines (23 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
namespace xString {
std::string fromWide(const std::wstring& text);
std::wstring toWide(const std::string& text);
template <typename T> [[nodiscard]] std::string cut(T what, const size_t to) {
std::ostringstream format;
format << std::setprecision(2) << what;
const auto output = format.str();
const auto str = output.c_str();
size_t size = 0;
for (size_t i = 0; i < output.size(); i++)
if (size < to)
size += (str[i] & 0xc0) != 0x80;
else
return output.substr(0, i);
return output;
}
[[nodiscard]] std::vector<std::string> split(const std::string& source, char delim, int maxTokens = -1);
}