MCPcopy Create free account
hub / github.com/DFHack/dfhack / console_is_utf8

Function console_is_utf8

library/MiscUtils.cpp:666–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664 return out;
665}
666static bool console_is_utf8()
667{
668#ifdef LINUX_BUILD
669 static bool checked = false;
670 static bool is_utf = false;
671 if (checked)
672 return is_utf;
673
674 std::string locale = "";
675 if (getenv("LANG"))
676 locale += getenv("LANG");
677 if (getenv("LC_CTYPE"))
678 locale += getenv("LC_CTYPE");
679 locale = toUpper_cp437(locale);
680 is_utf = (locale.find("UTF-8") != std::string::npos) || (locale.find("UTF8") != std::string::npos);
681 checked = true;
682 return is_utf;
683#else
684 return true; // Since DF 53.11, Windows console is always UTF-8
685#endif
686}
687
688DFHACK_EXPORT std::string DF2CONSOLE(const std::string &in)
689{

Callers 1

string DF2CONSOLEMethod · 0.85

Calls 2

toUpper_cp437Function · 0.85
findMethod · 0.45

Tested by

no test coverage detected