Skip to content

Commit b462fe4

Browse files
committed
Fixing up some conversion warnings on g++.
1 parent ac6ddaf commit b462fe4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ utf16string __cdecl conversions::utf8_to_utf16(const std::string &s)
276276
utf16string dest;
277277
// Save repeated heap allocations, use less than source string size assuming some
278278
// of the characters are not just ASCII and collapse.
279-
dest.reserve(static_cast<size_t>(s.size() * .70));
279+
dest.reserve(static_cast<size_t>(static_cast<double>(s.size()) * .70));
280280

281281
for (auto src = s.begin(); src != s.end(); ++src)
282282
{
@@ -385,10 +385,10 @@ std::string __cdecl conversions::utf16_to_utf8(const utf16string &w)
385385
codePoint |= SURROGATE_PAIR_START;
386386

387387
// 4 bytes need using 21 bits
388-
dest.push_back(char(codePoint >> 18) | 0xF0); // leading 3 bits
389-
dest.push_back(((codePoint >> 12) & LOW_6BITS) | BIT8); // next 6 bits
390-
dest.push_back(((codePoint >> 6) & LOW_6BITS) | BIT8); // next 6 bits
391-
dest.push_back((codePoint & LOW_6BITS) | BIT8); // trailing 6 bits
388+
dest.push_back(char((codePoint >> 18) | 0xF0)); // leading 3 bits
389+
dest.push_back(char(((codePoint >> 12) & LOW_6BITS) | BIT8)); // next 6 bits
390+
dest.push_back(char(((codePoint >> 6) & LOW_6BITS) | BIT8)); // next 6 bits
391+
dest.push_back(char((codePoint & LOW_6BITS) | BIT8)); // trailing 6 bits
392392
}
393393
else
394394
{
@@ -398,14 +398,14 @@ std::string __cdecl conversions::utf16_to_utf8(const utf16string &w)
398398
}
399399
else if (*src <= 0x7FF) // 2 bytes needed (11 bits used)
400400
{
401-
dest.push_back(char(*src >> 6) | 0xC0); // leading 5 bits
402-
dest.push_back((*src & LOW_6BITS) | BIT8); // trailing 6 bits
401+
dest.push_back(char((*src >> 6) | 0xC0)); // leading 5 bits
402+
dest.push_back(char((*src & LOW_6BITS) | BIT8)); // trailing 6 bits
403403
}
404404
else // 3 bytes needed (16 bits used)
405405
{
406-
dest.push_back((*src >> 12) | 0xE0); // leading 4 bits
407-
dest.push_back(((*src >> 6) & LOW_6BITS) | BIT8); // middle 6 bits
408-
dest.push_back((*src & LOW_6BITS) | BIT8); // trailing 6 bits
406+
dest.push_back(char((*src >> 12) | 0xE0)); // leading 4 bits
407+
dest.push_back(char(((*src >> 6) & LOW_6BITS) | BIT8)); // middle 6 bits
408+
dest.push_back(char((*src & LOW_6BITS) | BIT8)); // trailing 6 bits
409409
}
410410
}
411411
}

0 commit comments

Comments
 (0)