-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Remove /source-charset:utf-8
compile option.
#2938
Conversation
wchar_t's size (and UTF-16'ness) is Windows-specific; AIUI this approach isn't portable to the other platforms fmt supports |
This code is already guarded with |
test/std-test.cc
Outdated
@@ -16,7 +16,11 @@ TEST(std_test, path) { | |||
"\"foo\\\"bar.txt\""); | |||
|
|||
# ifdef _WIN32 | |||
EXPECT_EQ(fmt::format("{}", std::filesystem::path(L"Файл.txt")), | |||
// File.txt in Russian. | |||
// Do not use utf-8 encoded chars in this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is a bit misleading because we actually use UTF-8 below. There is still a question whether it should be escaped or not but it's still UTF-8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment updated.
test/std-test.cc
Outdated
// Do not use utf-8 encoded chars in this file. | ||
const wchar_t cyrillic_path[] = {0x424, 0x430, 0x439, 0x43b, 0x2e, | ||
0x74, 0x78, 0x74, 0}; | ||
EXPECT_EQ(fmt::format("{}", std::filesystem::path(cyrillic_path)), | ||
"\"\xd0\xa4\xd0\xb0\xd0\xb9\xd0\xbb.txt\""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use UTF-8 without escape sequences here as we do in format-test
:
Line 175 in 2471875
auto u = fmt::detail::utf8_to_utf16("лошадка"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good, a few comments inline.
fmt uses the Lines 84 to 87 in fb991e9
Therefore, I cannot set the My mistake was choosing the
|
2dec732
to
a8fca2d
Compare
Signed-off-by: Vladislav Shchapov <[email protected]>
Merged, thanks! |
Integrating
fmt
into my projects revealed the issue (https://godbolt.org/z/GqKEGexvo):Compile options
/utf-8
,/source-charset:utf-8
,/execution-charset:utf-8
are not compatible in any combination.I'm using the globally set
/utf-8
option, which results in an error when adding fmt with tests.We can solve this problem globally by removing the '/source-charset:utf-8' option and replacing the string literal
L"Файл.txt"
with awchar_t
representation.@vitaut, What do you think about this?