2323
2424#include < algorithm>
2525#include < atomic>
26+ #include < cstddef>
2627#include < cstdint>
2728#include < limits>
2829#include < string>
@@ -135,15 +136,14 @@ std::string Utf16ToUtf8(const wchar_t* ptr, size_t size) {
135136 }
136137 const int chars_len = static_cast <int >(size);
137138 std::string result;
138- std::int32_t len = std::max<std::int32_t >(
139- static_cast <std::int32_t >(std::min<size_t >(
140- result.capacity (), std::numeric_limits<std::int32_t >::max ())),
141- 1 );
139+ std::size_t len = std::max<std::size_t >(
140+ std::min<size_t >(result.capacity (), std::numeric_limits<int >::max ()), 1 );
142141 do {
143142 result.resize (len);
144143 // TODO: Switch to std::string::data() when we require C++17 or higher.
145- len = ::WideCharToMultiByte (CP_UTF8, WC_ERR_INVALID_CHARS, ptr, chars_len,
146- &result[0 ], len, nullptr , nullptr );
144+ len = static_cast <std::size_t >(::WideCharToMultiByte (
145+ CP_UTF8, WC_ERR_INVALID_CHARS, ptr, chars_len, &result[0 ],
146+ static_cast <int >(len), nullptr , nullptr ));
147147 } while (len > result.size ());
148148 result.resize (len);
149149 return result;
@@ -163,15 +163,14 @@ std::string GetWindowsLocalTimeZone() {
163163 }
164164
165165 std::wstring result;
166- std::int32_t len = std::max<std::int32_t >(
167- static_cast <std::int32_t >(std::min<size_t >(
168- result.capacity (), std::numeric_limits<std::int32_t >::max ())),
169- 1 );
166+ std::size_t len = std::max<std::size_t >(
167+ std::min<size_t >(result.capacity (), std::numeric_limits<int >::max ()), 1 );
170168 for (;;) {
171169 UErrorCode status = U_ZERO_ERROR;
172170 result.resize (len);
173- len = getTimeZoneIDForWindowsID (info.TimeZoneKeyName , -1 , nullptr ,
174- &result[0 ], len, &status);
171+ len = static_cast <std::size_t >(
172+ getTimeZoneIDForWindowsID (info.TimeZoneKeyName , -1 , nullptr , &result[0 ],
173+ static_cast <int >(len), &status));
175174 if (U_SUCCESS (status)) {
176175 return Utf16ToUtf8 (result.data (), len);
177176 }
0 commit comments