@@ -276,7 +276,7 @@ utf16string __cdecl conversions::utf8_to_utf16(const std::string &s)
276
276
utf16string dest;
277
277
// Save repeated heap allocations, use less than source string size assuming some
278
278
// 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 ));
280
280
281
281
for (auto src = s.begin (); src != s.end (); ++src)
282
282
{
@@ -385,10 +385,10 @@ std::string __cdecl conversions::utf16_to_utf8(const utf16string &w)
385
385
codePoint |= SURROGATE_PAIR_START;
386
386
387
387
// 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
392
392
}
393
393
else
394
394
{
@@ -398,14 +398,14 @@ std::string __cdecl conversions::utf16_to_utf8(const utf16string &w)
398
398
}
399
399
else if (*src <= 0x7FF ) // 2 bytes needed (11 bits used)
400
400
{
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
403
403
}
404
404
else // 3 bytes needed (16 bits used)
405
405
{
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
409
409
}
410
410
}
411
411
}
0 commit comments