3#include <ntr/ntr_Include.hpp>
7 inline std::string ConvertFromUnicode(
const std::u16string &u_str) {
8 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
char16_t> convert;
9 return convert.to_bytes(u_str);
12 inline std::u16string ConvertToUnicode(
const std::string &str) {
13 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
char16_t> convert;
14 return convert.from_bytes(str);
17 inline bool ConvertStringToNumber(
const std::string &str, u32 &out_num,
const u32 base = 10) {
20 const auto res = std::strtoul(str.c_str(), &end_ptr, base);
21 if((errno != 0) || (end_ptr == str.c_str())) {
30 template<
size_t N,
typename C>
31 inline std::basic_string<C> GetNonNullTerminatedCString(
const C (&c_str)[N]) {
32 const auto actual_len = std::min(N, std::char_traits<C>::length(c_str));
33 return std::basic_string<C>(c_str, actual_len);
36 template<
size_t N,
typename C>
37 inline void SetNonNullTerminatedCString(C (&out_c_str)[N],
const std::basic_string<C> &str) {
38 const auto actual_len = std::min(N, str.length());
39 std::memset(out_c_str, 0, N *
sizeof(C));
40 std::memcpy(out_c_str, str.c_str(), actual_len *
sizeof(C));
43 inline std::string ToLowerString(
const std::string &str) {
45 std::transform(str.begin(), str.end(), lower_str.begin(), ::tolower);
49 std::vector<std::string> SplitString(
const std::string &str,
const char separator);