From c84a88d35a499e16fce9a7886b2527ac001ecccb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 2 Jun 2014 16:01:13 -0700 Subject: [PATCH] GUAC-718: Set locale (for sake of wcwidth()). Warn if locale does not use UTF-8. --- src/protocols/ssh/client.c | 7 +++++++ src/protocols/telnet/client.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c index ea1d1493..f370b5d1 100644 --- a/src/protocols/ssh/client.c +++ b/src/protocols/ssh/client.c @@ -28,6 +28,8 @@ #include "ssh_client.h" #include "terminal.h" +#include +#include #include #include #include @@ -130,6 +132,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { return -1; } + /* Set locale and warn if not UTF-8 */ + setlocale(LC_CTYPE, ""); + if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0) + guac_client_log_info(client, "Current locale does not use UTF-8. Some characters may not render correctly."); + /* Read parameters */ strcpy(client_data->hostname, argv[IDX_HOSTNAME]); strcpy(client_data->username, argv[IDX_USERNAME]); diff --git a/src/protocols/telnet/client.c b/src/protocols/telnet/client.c index fce5cb82..b76bf839 100644 --- a/src/protocols/telnet/client.c +++ b/src/protocols/telnet/client.c @@ -27,6 +27,8 @@ #include "telnet_client.h" #include "terminal.h" +#include +#include #include #include #include @@ -92,6 +94,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { return -1; } + /* Set locale and warn if not UTF-8 */ + setlocale(LC_CTYPE, ""); + if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0) + guac_client_log_info(client, "Current locale does not use UTF-8. Some characters may not render correctly."); + /* Read parameters */ strcpy(client_data->hostname, argv[IDX_HOSTNAME]);