diff --git a/xterm/config b/xterm/config
index a5fbd0299..2d40a006c 100644
--- a/xterm/config
+++ b/xterm/config
@@ -1,2 +1,4 @@
+xterm=xterm-256color
base_port=555
rcfile=0
+locale=0
diff --git a/xterm/config.info b/xterm/config.info
index d7df4b8eb..b3fdaa737 100644
--- a/xterm/config.info
+++ b/xterm/config.info
@@ -1,3 +1,5 @@
+xterm=Set TERM environmental variable to,4,xterm+256color-xterm-256color,xterm+16color-xterm-16color,xterm-xterm,vt102-vt102,vt100-vt100,vt52-vt52,rxvt-rxvt,nsterm-nsterm,dtterm-dtterm,ansi-ansi
base_port=Base port number for WebSockets connections,0,5
size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24)
+locale=Set shell character encoding,10,0-Shell default,1-en_US.UTF-8,Custom
rcfile=Execute initialization commands from file,10,0-Shell default,1-Module default,Custom
diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl
index 3b932e5db..23da516b2 100755
--- a/xterm/shellserver.pl
+++ b/xterm/shellserver.pl
@@ -28,9 +28,23 @@ else {
&foreign_require("proc");
&clean_environment();
+# Set locale
+my $lang = $config{'locale'};
+if ($lang) {
+ my @opts = ('LC_ALL', 'LANG', 'LANGUAGE');
+ $lang = 'en_US.UTF-8' if ($lang == 1);
+ foreach my $opt (@opts) {
+ $ENV{$opt} = &trim($lang);
+ }
+ }
+
# Set terminal
$ENV{'USER'} = $user;
-$ENV{'TERM'} = 'xterm-256color';
+my $config_xterm = $config{'xterm'};
+$config_xterm = 'xterm-256color'
+ if (!$config_xterm);
+$config_xterm =~ s/\+/-/;
+$ENV{'TERM'} = $config_xterm;
$ENV{'HOME'} = $uinfo[7];
chdir($dir || $uinfo[7] || "/");
my $shellcmd = $uinfo[8];