Skip to content

Commit

Permalink
Merge pull request #607 from doomlaur/bugfix/windows_utf16_paths
Browse files Browse the repository at this point in the history
Paths on Windows are now correctly converted from UTF-8 to UTF-16
  • Loading branch information
tfussell committed Jan 9, 2022
2 parents 69f651e + 732cbe0 commit 0246c7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/utils/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const std::string &path::string() const
#ifdef _MSC_VER
std::wstring path::wstring() const
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
return convert.from_bytes(string());
}
#endif
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions tests/workbook/serialization_test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,18 @@ class serialization_test_suite : public test_suite
{
#ifdef _MSC_VER
xlnt::workbook wb;
// L"/9_unicode_Λ.xlsx" doesn't use wchar_t(0x039B) for the capital lambda...
// L"/9_unicode_\u039B.xlsx" gives the corrct output
const auto path = LSTRING_LITERAL(XLNT_TEST_DATA_DIR) L"/9_unicode_\u039B.xlsx"; // L"/9_unicode_Λ.xlsx"
// L"/9_unicode_Λ_😇.xlsx" doesn't use wchar_t(0x039B) for the capital lambda...
// L"/9_unicode_\u039B_\U0001F607.xlsx" gives the correct output
const auto path = LSTRING_LITERAL(XLNT_TEST_DATA_DIR) L"/9_unicode_\u039B_\U0001F607.xlsx"; // L"/9_unicode_Λ_😇.xlsx"
wb.load(path);
xlnt_assert_equals(wb.active_sheet().cell("A1").value<std::string>(), u8"un\u00EFc\u00F4d\u0117!"); // u8"unïcôdė!"
#endif

#ifndef __MINGW32__
xlnt::workbook wb2;
// u8"/9_unicode_Λ.xlsx" doesn't use 0xc3aa for the capital lambda...
// u8"/9_unicode_\u039B.xlsx" gives the corrct output
const auto path2 = U8STRING_LITERAL(XLNT_TEST_DATA_DIR) u8"/9_unicode_\u039B.xlsx"; // u8"/9_unicode_Λ.xlsx"
// u8"/9_unicode_Λ_😇.xlsx" doesn't use 0xC3AA for the capital lambda...
// u8"/9_unicode_\u039B_\U0001F607.xlsx" gives the correct output
const auto path2 = U8STRING_LITERAL(XLNT_TEST_DATA_DIR) u8"/9_unicode_\u039B_\U0001F607.xlsx"; // u8"/9_unicode_Λ_😇.xlsx"
wb2.load(path2);
xlnt_assert_equals(wb2.active_sheet().cell("A1").value<std::string>(), u8"un\u00EFc\u00F4d\u0117!"); // u8"unïcôdė!"
#endif
Expand Down Expand Up @@ -633,9 +633,9 @@ class serialization_test_suite : public test_suite

void test_round_trip_rw_unicode()
{
// u8"/9_unicode_Λ.xlsx" doesn't use 0xc3aa for the capital lambda...
// u8"/9_unicode_\u039B.xlsx" gives the corrct output
xlnt_assert(round_trip_matches_rw(path_helper::test_file(u8"9_unicode_\u039B.xlsx")));
// u8"/9_unicode_Λ_😇.xlsx" doesn't use 0xC3AA for the capital lambda...
// u8"/9_unicode_\u039B_\U0001F607.xlsx" gives the correct output
xlnt_assert(round_trip_matches_rw(path_helper::test_file(u8"9_unicode_\u039B_\U0001F607.xlsx")));
}

void test_round_trip_rw_comments_hyperlinks_formulae()
Expand Down

0 comments on commit 0246c7b

Please sign in to comment.