31 #ifndef HELPER_PORTABILITY_LOCALE_H_ 32 #define HELPER_PORTABILITY_LOCALE_H_ 42 #include "../Strings.hpp" 43 #include "../System.hpp" 49 inline constexpr
auto localeBufferSize{1024};
62 BOOL CALLBACK addLocale(LPWSTR pStr, DWORD dwFlags, LPARAM lparam) {
63 WCHAR wcBuffer[localeBufferSize];
66 if(GetLocaleInfoEx(pStr, LOCALE_SENGLANGUAGE, wcBuffer, localeBufferSize)) {
67 GetLocaleInfoEx(pStr, LOCALE_SENGLANGUAGE, wcBuffer, localeBufferSize);
69 std::wstring wstr(wcBuffer);
71 reinterpret_cast<std::vector<std::string> *
>(
72 lparam)->emplace_back(wstr.cbegin(), wstr.cend()
86 std::vector<std::string> result;
89 EnumSystemLocalesEx(addLocale, LOCALE_ALL, reinterpret_cast<LPARAM>(&result), NULL);
Namespace for global portability functions.
Definition: getch.h:44
std::string exec(const char *cmd)
Executes a system command and returns the stdout of the program.
Definition: System.hpp:64
std::vector< std::string > enumLocales()
Enumerates all available locale on the system.
Definition: locale.h:85
std::vector< std::string > split(const std::string &str, char delimiter)
Splits a string into a vector of strings using the given delimiter.
Definition: Strings.hpp:739