|
54 | 54 | #endif // __has_include |
55 | 55 | #endif // _WIN32 |
56 | 56 |
|
| 57 | +#include <array> |
| 58 | +#include <cstdint> |
57 | 59 | #include <cstdlib> |
58 | 60 | #include <cstring> |
59 | 61 | #include <string> |
@@ -115,22 +117,22 @@ std::string win32_local_time_zone() { |
115 | 117 | return ""; |
116 | 118 | } |
117 | 119 |
|
118 | | - UChar buffer[128]; |
| 120 | + std::array<UChar, 128> buffer; |
119 | 121 | UErrorCode status = U_ZERO_ERROR; |
120 | 122 | const auto num_chars_in_buffer = ucal_getTimeZoneIDForWindowsIDFunc( |
121 | 123 | reinterpret_cast<const UChar*>(info.TimeZoneKeyName), -1, nullptr, |
122 | | - buffer, ARRAYSIZE(buffer), &status); |
| 124 | + buffer.data(), static_cast<int32_t>(buffer.size()), &status); |
123 | 125 | if (status != U_ZERO_ERROR || num_chars_in_buffer <= 0 || |
124 | | - num_chars_in_buffer > ARRAYSIZE(buffer)) { |
| 126 | + num_chars_in_buffer > static_cast<int32_t>(buffer.size())) { |
125 | 127 | return ""; |
126 | 128 | } |
127 | 129 |
|
128 | 130 | const int num_bytes_in_utf8 = ::WideCharToMultiByte( |
129 | | - CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer), |
| 131 | + CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer.data()), |
130 | 132 | static_cast<int>(num_chars_in_buffer), nullptr, 0, nullptr, nullptr); |
131 | 133 | std::string local_time_str; |
132 | 134 | local_time_str.resize(static_cast<size_t>(num_bytes_in_utf8)); |
133 | | - ::WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer), |
| 135 | + ::WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer.data()), |
134 | 136 | static_cast<int>(num_chars_in_buffer), |
135 | 137 | &local_time_str[0], num_bytes_in_utf8, nullptr, |
136 | 138 | nullptr); |
|
0 commit comments