Mercurial > minori
comparison src/core/strings.cpp @ 62:4c6dd5999b39
*: update
1. updated animia
2. use widestrings for filesystem on Windows
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 01 Oct 2023 06:16:06 -0400 |
| parents | cde8f67a7c7d |
| children | fe719c109dbc |
comparison
equal
deleted
inserted
replaced
| 61:327568ad9be9 | 62:4c6dd5999b39 |
|---|---|
| 2 * strings.cpp: Useful functions for manipulating strings | 2 * strings.cpp: Useful functions for manipulating strings |
| 3 **/ | 3 **/ |
| 4 #include "core/strings.h" | 4 #include "core/strings.h" |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <cctype> | 6 #include <cctype> |
| 7 #include <codecvt> | |
| 7 #include <locale> | 8 #include <locale> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 namespace Strings { | 12 namespace Strings { |
| 73 std::string result(string); | 74 std::string result(string); |
| 74 std::transform(result.begin(), result.end(), result.begin(), [](unsigned char c) { return std::tolower(c); }); | 75 std::transform(result.begin(), result.end(), result.begin(), [](unsigned char c) { return std::tolower(c); }); |
| 75 return result; | 76 return result; |
| 76 } | 77 } |
| 77 | 78 |
| 79 std::wstring ToWstring(const std::string& string) { | |
| 80 std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter; | |
| 81 return converter.from_bytes(string); | |
| 82 } | |
| 83 | |
| 84 std::string ToUtf8String(const std::wstring& wstring) { | |
| 85 std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter; | |
| 86 return converter.to_bytes(wstring); | |
| 87 } | |
| 88 | |
| 78 } // namespace Strings | 89 } // namespace Strings |
