@@ -171,8 +171,8 @@ std::vector<std::string> narrow_argv(int argc, const wchar_t **argv_wide)
171
171
// / \return A 16-bit integer with bytes swapped
172
172
uint16_t do_swap_bytes (uint16_t x)
173
173
{
174
- uint16_t b1= x & 0xFF ;
175
- uint16_t b2= x & 0xFF00 ;
174
+ const uint16_t b1 = x & 0xFFu ;
175
+ const uint16_t b2 = x & 0xFF00u ;
176
176
return (b1 << 8 ) | (b2 >> 8 );
177
177
}
178
178
@@ -185,7 +185,8 @@ void utf16_append_code(unsigned int code, bool swap_bytes, std::wstring &result)
185
185
if (code<0xFFFF )
186
186
{ // code is encoded as one UTF16 character
187
187
// we just take the code and possibly swap the bytes
188
- unsigned int a=(swap_bytes)?do_swap_bytes (code):code;
188
+ const unsigned int a =
189
+ swap_bytes ? do_swap_bytes (static_cast <uint16_t >(code)) : code;
189
190
result+=static_cast <wchar_t >(a);
190
191
}
191
192
else // code is encoded as two UTF16 characters
@@ -196,11 +197,11 @@ void utf16_append_code(unsigned int code, bool swap_bytes, std::wstring &result)
196
197
197
198
// encode the code in UTF16, possibly swapping bytes.
198
199
code=code-0x10000 ;
199
- unsigned int i1=(( code>> 10 ) & 0x3ff ) | 0xD800 ;
200
- unsigned int a1=( swap_bytes)? do_swap_bytes (static_cast < uint16_t >( i1)): i1;
200
+ const uint16_t i1 = static_cast < uint16_t >((( code >> 10 ) & 0x3ff ) | 0xD800 ) ;
201
+ const uint16_t a1 = swap_bytes ? do_swap_bytes (i1) : i1;
201
202
result+=static_cast <wchar_t >(a1);
202
- unsigned int i2=( code & 0x3ff ) | 0xDC00 ;
203
- unsigned int a2=( swap_bytes)? do_swap_bytes (static_cast < uint16_t >( i2)): i2;
203
+ const uint16_t i2 = static_cast < uint16_t >(( code & 0x3ff ) | 0xDC00 ) ;
204
+ const uint16_t a2 = swap_bytes ? do_swap_bytes (i2) : i2;
204
205
result+=static_cast <wchar_t >(a2);
205
206
}
206
207
}
0 commit comments