Revert "[lldb] improve the heuristics for checking if a terminal supports Unicode (#168603)#170711
Merged
charles-zablit merged 1 commit intollvm:mainfrom Dec 4, 2025
Conversation
…orts Unicode (llvm#168603)" This reverts commit 64e1991.
Member
|
@llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) ChangesThis reverts commit 64e1991. #168603 breaks the CI because the bots support Unicode but the tests expect non Unicode characters. Full diff: https://github.com/llvm/llvm-project/pull/170711.diff 3 Files Affected:
diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h
index 3d66515c18812..da0d05e8bd265 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -68,18 +68,6 @@ class Terminal {
llvm::Error SetHardwareFlowControl(bool enabled);
- /// Returns whether or not the current terminal supports Unicode rendering.
- ///
- /// The value is cached after the first computation.
- ///
- /// On POSIX systems, we check if the LANG environment variable contains the
- /// substring "UTF-8", case insensitive.
- ///
- /// On Windows, we always return true since we use the `WriteConsoleW` API
- /// internally. Note that the default Windows codepage (437) does not support
- /// all Unicode characters. This function does not check the codepage.
- static bool SupportsUnicode();
-
protected:
struct Data;
diff --git a/lldb/source/Host/common/DiagnosticsRendering.cpp b/lldb/source/Host/common/DiagnosticsRendering.cpp
index 375d1caa99f52..f2cd3968967fb 100644
--- a/lldb/source/Host/common/DiagnosticsRendering.cpp
+++ b/lldb/source/Host/common/DiagnosticsRendering.cpp
@@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/common/DiagnosticsRendering.h"
-#include "lldb/Host/Terminal.h"
-
#include <cstdint>
using namespace lldb_private;
@@ -99,8 +97,12 @@ void RenderDiagnosticDetails(Stream &stream,
return;
}
+ // Since there is no other way to find this out, use the color
+ // attribute as a proxy for whether the terminal supports Unicode
+ // characters. In the future it might make sense to move this into
+ // Host so it can be customized for a specific platform.
llvm::StringRef cursor, underline, vbar, joint, hbar, spacer;
- if (Terminal::SupportsUnicode()) {
+ if (stream.AsRawOstream().colors_enabled()) {
cursor = "˄";
underline = "˜";
vbar = "│";
diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp
index dd1dc75133f45..436dfd8130d9b 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -400,21 +400,6 @@ llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
#endif // LLDB_ENABLE_TERMIOS
}
-bool Terminal::SupportsUnicode() {
- static std::optional<bool> result;
- if (result)
- return result.value();
-#ifdef _WIN32
- return true;
-#else
- const char *lang_var = std::getenv("LANG");
- if (!lang_var)
- return false;
- result = llvm::StringRef(lang_var).lower().find("utf-8") != std::string::npos;
-#endif
- return result.value();
-}
-
TerminalState::TerminalState(Terminal term, bool save_process_group)
: m_tty(term) {
Save(term, save_process_group);
|
dzhidzhoev
approved these changes
Dec 4, 2025
Member
dzhidzhoev
left a comment
There was a problem hiding this comment.
(AFAIK approval is not necessary for (self-)reverting commits, though skip-precommit-approval tag is required)
honeygoyal
pushed a commit
to honeygoyal/llvm-project
that referenced
this pull request
Dec 9, 2025
…orts Unicode (llvm#168603) (llvm#170711) This reverts commit 64e1991. llvm#168603 breaks the CI because the bots support Unicode but the tests expect non Unicode characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reverts commit 64e1991.
#168603 breaks the CI because the bots support Unicode but the tests expect non Unicode characters.