mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Setup UTF8 locale
This commit is contained in:
parent
55c8c19f67
commit
1cd1bb0965
@ -130,6 +130,25 @@ static char* get_full_hostname(void)
|
||||
freeaddrinfo(info);
|
||||
return ret;
|
||||
}
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
|
||||
static void setup_locale(void)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) {
|
||||
if (setlocale(LC_CTYPE, "") == NULL)
|
||||
tmate_fatal("invalid LC_ALL, LC_CTYPE or LANG");
|
||||
s = nl_langinfo(CODESET);
|
||||
if (strcasecmp(s, "UTF-8") != 0 &&
|
||||
strcasecmp(s, "UTF8") != 0)
|
||||
tmate_fatal("need UTF-8 locale (LC_CTYPE) but have %s", s);
|
||||
}
|
||||
|
||||
setlocale(LC_TIME, "");
|
||||
tzset();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
@ -167,6 +186,8 @@ int main(int argc, char **argv, char **envp)
|
||||
init_logging("tmate-remote-tmux",
|
||||
tmate_settings->use_syslog, tmate_settings->log_level);
|
||||
|
||||
setup_locale();
|
||||
|
||||
if (!tmate_settings->tmate_host)
|
||||
tmate_settings->tmate_host = get_full_hostname();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user