mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
use en_US.UTF-8 locale in utf8.tolower, toupper functions
This commit is contained in:
parent
3147897709
commit
36959807bd
2 changed files with 20 additions and 16 deletions
|
|
@ -507,22 +507,32 @@ double util::parse_double(const std::string& str, size_t offset, size_t len) {
|
|||
return parse_double(str.substr(offset, len));
|
||||
}
|
||||
|
||||
std::wstring util::lower_case(const std::wstring& str) {
|
||||
std::wstring result = str;
|
||||
template<typename CharT>
|
||||
static std::basic_string<CharT> lower_case(const std::basic_string<CharT>& str) {
|
||||
std::basic_string<CharT> result = str;
|
||||
for (uint i = 0; i < result.length(); i++) {
|
||||
result[i] = static_cast<wchar_t>(std::tolower(str[i], locale));
|
||||
result[i] = std::tolower(str[i], locale);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring util::upper_case(const std::wstring& str) {
|
||||
std::wstring result = str;
|
||||
template<typename CharT>
|
||||
static std::basic_string<CharT> upper_case(const std::basic_string<CharT>& str) {
|
||||
std::basic_string<CharT> result = str;
|
||||
for (uint i = 0; i < result.length(); i++) {
|
||||
result[i] = static_cast<wchar_t>(std::toupper(str[i], locale));
|
||||
result[i] = std::toupper(str[i], locale);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring util::lower_case(const std::wstring& str) {
|
||||
return ::lower_case(str);
|
||||
}
|
||||
|
||||
std::wstring util::upper_case(const std::wstring& str) {
|
||||
return ::upper_case(str);
|
||||
}
|
||||
|
||||
std::wstring util::capitalized(const std::wstring& str) {
|
||||
if (str.empty()) return str;
|
||||
return std::wstring({static_cast<wchar_t>(std::toupper(str[0], locale))}) +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue