Skip to content

Commit 0f32c13

Browse files
KKiiimatc-github
authored andcommitted
fix(MSVC compatibility): use escaped UTF-8 block characters instead of raw Unicode (#725)
1 parent 1145935 commit 0f32c13

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

extensions/Analytics.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "Analytics.hpp"
2424

2525
#include "src/core/compiler/common/StackElement.hpp"
26-
#include "src/core/compiler/common/StackType.hpp"
2726

2827
namespace vb {
2928
namespace extension {
@@ -48,8 +47,13 @@ void Analytics::updateMemoryUsage(MemoryUsage &memoryUsage, uint32_t const compi
4847
/// @param maxBlocks Max number of blocks
4948
/// @param end String to print after the line
5049
void printGraphLine(float const percent, uint32_t const maxBlocks, std::string const &end = "\n") {
51-
constexpr char fullBlock[4] = ""; // NOLINT(modernize-avoid-c-arrays)
52-
constexpr std::array<char[4], 8> blockChars = {"", "", "", "", "", "", "", ""}; // NOLINT(modernize-avoid-c-arrays)
50+
// Use explicit UTF-8 byte escape sequences so source remains pure ASCII and works on MSVC/GCC/Clang without /utf-8.
51+
// Unicode: FULL BLOCK U+2588, LEFT 1/8..7/8 BLOCK U+258F..U+2589
52+
//
53+
constexpr const char *fullBlock = "\xE2\x96\x88";
54+
// "", "▏", "▎", "▍", "▌", "▋", "▊", "▉"
55+
constexpr std::array<const char *, 8> blockChars{
56+
"", "\xE2\x96\x8F", "\xE2\x96\x8E", "\xE2\x96\x8D", "\xE2\x96\x8C", "\xE2\x96\x8B", "\xE2\x96\x8A", "\xE2\x96\x89"};
5357

5458
uint32_t const fullBlocks = static_cast<uint32_t>(percent * static_cast<float>(maxBlocks));
5559
uint32_t const eightsBlocks = static_cast<uint32_t>((percent * static_cast<float>(maxBlocks) - static_cast<float>(fullBlocks)) / 0.125F);

0 commit comments

Comments
 (0)