Skip to content

Commit

Permalink
Set execution charset to utf-8 for VS
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 10, 2020
1 parent 01b7b7d commit e0c026b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
32 changes: 12 additions & 20 deletions far/encoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,19 +1268,6 @@ bool encoding::is_valid_utf8(std::string_view const Str, bool const PartialConte

#include "testing.hpp"

// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0482r6.html#design_compat
// "This proposal does not specify any backward compatibility features other than to retain interfaces that it deprecates.
// The author believes such features are necessary, but that a single set of such features would unnecessarily compromise the goals of this proposal.
// Rather, the expectation is that implementations will provide options to enable more fine grained compatibility features."

// *facepalm*

template<typename char_type, REQUIRES(sizeof(char_type) == 1)>
std::string_view sane_sv(std::basic_string_view<char_type> const Str)
{
return { static_cast<const char*>(static_cast<const void*>(Str.data())), Str.size() };
}

TEST_CASE("encoding.utf8")
{
static const struct
Expand All @@ -1291,27 +1278,27 @@ TEST_CASE("encoding.utf8")
}
Tests[]
{
{ true, false, sane_sv(u8R"(
{ true, false, R"(
ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ
ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ
ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ᛬
)"sv) },
)"sv },

{ true, false, sane_sv(u8R"(
{ true, false, R"(
𠜎 𠜱 𠝹 𠱓 𠱸 𠲖 𠳏 𠳕 𠴕 𠵼 𠵿 𠸎
𠸏 𠹷 𠺝 𠺢 𠻗 𠻹 𠻺 𠼭 𠼮 𠽌 𠾴 𠾼
𠿪 𡁜 𡁯 𡁵 𡁶 𡁻 𡃁 𡃉 𡇙 𢃇 𢞵 𢫕
𢭃 𢯊 𢱑 𢱕 𢳂 𢴈 𢵌 𢵧 𢺳 𣲷 𤓓 𤶸
𤷪 𥄫 𦉘 𦟌 𦧲 𦧺 𧨾 𨅝 𨈇 𨋢 𨳊 𨳍
)"sv) },
)"sv },

{ true, true, sane_sv(u8R"(
{ true, true, R"(
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
)"sv) },
{ true, false, sane_sv(u8"φ"sv) },
)"sv },
{ true, false, "φ"sv },
{ false, false, "\x80"sv },
{ false, false, "\xFF"sv },
{ false, false, "\xC0"sv },
Expand Down Expand Up @@ -1398,4 +1385,9 @@ TEST_CASE("encoding.raw_eol")
REQUIRE(Eol.lf<wchar_t>() == '\n');
}
}

TEST_CASE("encoding.compiler_charset")
{
static_assert("𠜎𠜱"sv == "\xF0\xA0\x9C\x8E\xF0\xA0\x9C\xB1"sv);
}
#endif
2 changes: 2 additions & 0 deletions far/exception_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ static bool ExcConsole(
std::vector<DWORD64> const* const NestedStack
)
{
std::wcerr << L'\n';

for (const auto& [m, v]: zip(Labels, Values))
{
const auto Label = fit_to_left(string(m), max_item_size(Labels));
Expand Down
2 changes: 1 addition & 1 deletion far/far.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if not exist $(BootstrapDir) mkdir $(BootstrapDir)</Command>
</PreBuildEvent>
<ClCompile>
<AdditionalIncludeDirectories>$(BootstrapDir)..</AdditionalIncludeDirectories>
<AdditionalOptions>/J /Zc:__cplusplus,externConstexpr,inline,throwingNew /volatile:iso $(NewOptions) %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/J /Zc:__cplusplus,externConstexpr,inline,throwingNew /volatile:iso /utf-8 $(NewOptions) %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>_ENABLE_EXTENDED_ALIGNED_STORAGE;_HAS_AUTO_PTR_ETC=0;_CRT_SECURE_NO_WARNINGS;FAR_ALPHA_VERSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand Down
1 change: 1 addition & 0 deletions far/makefile_vc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ CPPFLAGS=\
/Zc:__cplusplus,externConstexpr,inline,throwingNew\
/volatile:iso\
/Wall\
/utf-8\
/Gy\
/GF\
/Fd"$(INTDIR)\\"\
Expand Down

0 comments on commit e0c026b

Please sign in to comment.