Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths on Windows are now correctly converted from UTF-8 to UTF-16 #607

Merged
merged 2 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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