Skip to content

Commit 95f6b3e

Browse files
Revert "[lldb] improve the heuristics for checking if a terminal supports Unicode (#168603) (#170711)
This reverts commit 64e1991. #168603 breaks the CI because the bots support Unicode but the tests expect non Unicode characters.
1 parent 08c2a86 commit 95f6b3e

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

lldb/include/lldb/Host/Terminal.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ class Terminal {
6868

6969
llvm::Error SetHardwareFlowControl(bool enabled);
7070

71-
/// Returns whether or not the current terminal supports Unicode rendering.
72-
///
73-
/// The value is cached after the first computation.
74-
///
75-
/// On POSIX systems, we check if the LANG environment variable contains the
76-
/// substring "UTF-8", case insensitive.
77-
///
78-
/// On Windows, we always return true since we use the `WriteConsoleW` API
79-
/// internally. Note that the default Windows codepage (437) does not support
80-
/// all Unicode characters. This function does not check the codepage.
81-
static bool SupportsUnicode();
82-
8371
protected:
8472
struct Data;
8573

lldb/source/Host/common/DiagnosticsRendering.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "lldb/Host/common/DiagnosticsRendering.h"
10-
#include "lldb/Host/Terminal.h"
11-
1210
#include <cstdint>
1311

1412
using namespace lldb_private;
@@ -99,8 +97,12 @@ void RenderDiagnosticDetails(Stream &stream,
9997
return;
10098
}
10199

100+
// Since there is no other way to find this out, use the color
101+
// attribute as a proxy for whether the terminal supports Unicode
102+
// characters. In the future it might make sense to move this into
103+
// Host so it can be customized for a specific platform.
102104
llvm::StringRef cursor, underline, vbar, joint, hbar, spacer;
103-
if (Terminal::SupportsUnicode()) {
105+
if (stream.AsRawOstream().colors_enabled()) {
104106
cursor = "˄";
105107
underline = "˜";
106108
vbar = "";

lldb/source/Host/common/Terminal.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,6 @@ llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
400400
#endif // LLDB_ENABLE_TERMIOS
401401
}
402402

403-
bool Terminal::SupportsUnicode() {
404-
static std::optional<bool> result;
405-
if (result)
406-
return result.value();
407-
#ifdef _WIN32
408-
return true;
409-
#else
410-
const char *lang_var = std::getenv("LANG");
411-
if (!lang_var)
412-
return false;
413-
result = llvm::StringRef(lang_var).lower().find("utf-8") != std::string::npos;
414-
#endif
415-
return result.value();
416-
}
417-
418403
TerminalState::TerminalState(Terminal term, bool save_process_group)
419404
: m_tty(term) {
420405
Save(term, save_process_group);

0 commit comments

Comments
 (0)