Euphoria
ctree.cc
Go to the documentation of this file.
1 #include "core/ctree.h"
2 
3 #include <cstdlib>
4 
5 #include "base/stringutils.h"
6 
7 namespace
8 {
9  bool is_terminal_supporting_utf8()
10  {
11  const auto* clang = std::getenv("LANG");
12 
13  if(clang != nullptr)
14  {
15  const auto lang = std::string(clang);
16  const auto lower = eu::to_lower(lang);
17  const auto ends = eu::ends_with(lower, "utf-8");
18  return ends;
19  }
20 
21  return false;
22  }
23 }
24 
25 namespace eu::core
26 {
27 
28 
30 {
31  if(is_terminal_supporting_utf8())
32  {
33  return utf8_tree_style;
34  }
35  else
36  {
37  return cross_style;
38  }
39 }
40 
41 }
std::string to_lower(const std::string &str)
Generate a string containing only lower characters.
Definition: stringutils.cc:143
TreeStyle determine_style()
Definition: ctree.cc:29
constexpr TreeStyle utf8_tree_style
Definition: ctree.h:31
constexpr TreeStyle cross_style
Definition: ctree.h:42
bool ends_with(const std::string &str, char c)
Definition: os.cc:139
String utility functions.