3#include <twl/twl_Include.hpp>
11 inline std::string ConvertFromUnicode(
const std::u16string &u_str) {
12 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
char16_t> convert;
13 return convert.to_bytes(u_str);
16 inline std::u16string ConvertToUnicode(
const std::string &str) {
17 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
char16_t> convert;
18 return convert.from_bytes(str);
21 inline bool ConvertStringToNumber(
const std::string &str, u32 &out_num,
const u32 base = 10) {
24 const auto res = std::strtoul(str.c_str(), &end_ptr, base);
25 if((errno != 0) || (end_ptr == str.c_str())) {
34 template<
size_t N,
typename C>
35 inline std::basic_string<C> GetNonNullTerminatedCString(
const C (&c_str)[N]) {
36 const auto actual_len = std::min(N, std::char_traits<C>::length(c_str));
37 return std::basic_string<C>(c_str, actual_len);
40 template<
size_t N,
typename C>
41 inline void SetNonNullTerminatedCString(C (&out_c_str)[N],
const std::basic_string<C> &str) {
42 const auto actual_len = std::min(N, str.length());
43 std::memset(out_c_str, 0, N *
sizeof(C));
44 std::memcpy(out_c_str, str.c_str(), actual_len *
sizeof(C));
47 inline std::string ToLowerString(
const std::string &str) {
49 std::transform(str.begin(), str.end(), lower_str.begin(), ::tolower);
53 std::vector<std::string> SplitString(
const std::string &str,
const char separator);