File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -440,7 +440,7 @@ utf16string __cdecl conversions::latin1_to_utf16(const std::string &s)
440440 dest.resize (s.size ());
441441 for (size_t i = 0 ; i < s.size (); ++i)
442442 {
443- dest[i] = utf16char (s[i]);
443+ dest[i] = utf16char (static_cast < unsigned char >( s[i]) );
444444 }
445445 return dest;
446446}
Original file line number Diff line number Diff line change @@ -278,13 +278,22 @@ TEST(utf8_to_utf16_errors)
278278
279279TEST (latin1_to_utf16)
280280{
281- // TODO: find some string that actually uses something unique to the Latin1 code page.
282- std::string str_latin1 (" This is a test" );
283- utf16string str_utf16 = utility::conversions::latin1_to_utf16 (str_latin1);
284-
285- for (size_t i = 0 ; i < str_latin1.size (); ++i)
281+ char in[256 ] = { 0 };
282+ char16_t expectedResult[256 ] = { 0 };
283+ for (size_t i = 0 ; i < 256 ; ++i)
284+ {
285+ in[i] = static_cast <char >(i);
286+ expectedResult[i] = static_cast <char16_t >(i);
287+ }
288+
289+ std::string str_latin1 (in, 256 );
290+
291+ auto actualResult = utility::conversions::latin1_to_utf16 (str_latin1);
292+
293+ VERIFY_ARE_EQUAL (str_latin1.size (), actualResult.size ());
294+ for (size_t i = 0 ; i < actualResult.size (); ++i)
286295 {
287- VERIFY_ARE_EQUAL ((utf16char)str_latin1 [i], str_utf16 [i]);
296+ VERIFY_ARE_EQUAL (expectedResult [i], actualResult [i]);
288297 }
289298}
290299
You can’t perform that action at this time.
0 commit comments