<div dir="ltr">Hello Goffredo,<div><br></div><div>I&#39;m afraid there&#39;s no good answer here within the context of the C/POSIX locale system. If mosh didn&#39;t complain, some other locale-sensitive program on the server would complain (e.g. perl, or basically anything). ssh (as shipped by OS X/Debian/Ubuntu) also passes the locale-related environment variables, and you would have the same problem there.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">We&#39;re moving to a world where Mosh will not use the C locale support at all to do UTF-8 decoding and get character widths, but that will just make this somebody else&#39;s problem.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Your good options are basically:</div><div class="gmail_extra">(1) Unset LC_TIME before you mosh (e.g. LC_TIME= mosh servername).</div><div class="gmail_extra">
(2) Build the client&#39;s locale on the server.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-Keith</div><div class="gmail_extra"><br></div><div class="gmail_extra">On Tue, Dec 10, 2013 at 2:23 PM, Goffredo Baroncelli <span dir="ltr">&lt;<a href="mailto:kreijack@inwind.it" target="_blank">kreijack@inwind.it</a>&gt;</span> wrote:<br>

</div><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Keith,<br>
<div><br>
On 2013-12-10 20:11, Keith Winstein wrote:<br>
&gt; Goffredo,<br>
&gt;<br>
&gt; Unfortunately this is a general problem with the C/POSIX locale system.<br>
&gt; Even British users (in en_GB.UTF-8) have trouble connecting to Canadian<br>
&gt; machines in (en_CA.UTF-8)! If you give us the actual error report you&#39;re<br>
&gt; getting from mosh-client or mosh-server, I may have a better answer for<br>
&gt; what the right thing to do is. We have made the diagnostics pretty<br>
&gt; extensive in 1.2 and later versions.<br>
<br>
<br>
<br>
</div>-------------------------------------client-------------------------<br>
server$ set | egrep &quot;LANG|LC_&quot;<br>
LANG=en_US.UTF-8<br>
LC_TIME=en_DK.utf8                         # this var is set by ssh<br>
server$ locale -a<br>
C<br>
C.UTF-8<br>
en_US.utf8<br>
italian<br>
it_IT<br>
it_IT@euro<br>
it_IT.iso88591<br>
it_IT.iso885915@euro<br>
it_IT.utf8<br>
POSIX<br>
$ mosh --version<br>
mosh 1.2.4a<br>
Copyright 2012 Keith Winstein &lt;<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>&gt;<br>
License GPLv3+: GNU GPL version 3 or later<br>
&lt;<a href="http://gnu.org/licenses/gpl.html" target="_blank">http://gnu.org/licenses/gpl.html</a>&gt;.<br>
This is free software: you are free to change and redistribute it.<br>
There is NO WARRANTY, to the extent permitted by law.<br>
<br>
<br>
-------------------------------------server-------------------------<br>
client$ set | egrep &quot;LANG|LC_&quot;<br>
LANG=en_US.utf8<br>
LC_TIME=en_DK.utf8<br>
client$ locale -a<br>
C<br>
C.UTF-8<br>
en_DK.utf8<br>
en_US.utf8<br>
italian<br>
it_IT<br>
it_IT@euro<br>
it_IT.iso88591<br>
it_IT.iso885915@euro<br>
it_IT.utf8<br>
POSIX<br>
client$ mosh --version<br>
mosh 1.2.4a<br>
Copyright 2012 Keith Winstein &lt;<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>&gt;<br>
License GPLv3+: GNU GPL version 3 or later<br>
&lt;<a href="http://gnu.org/licenses/gpl.html" target="_blank">http://gnu.org/licenses/gpl.html</a>&gt;.<br>
This is free software: you are free to change and redistribute it.<br>
There is NO WARRANTY, to the extent permitted by law.<br>
---------------------------------------------------------------------------<br>
<br>
<br>
Both the machine support en_US.utf8; however the client has<br>
LC_TIME=en_DK.utf8 which isn&#39;t supported in the server.<br>
<br>
<br>
<br>
client$ mosh server<br>
ghigo@client&#39;s password:<br>
The locale requested by LANG=en_US.UTF-8 isn&#39;t available here.<br>
Running `locale-gen en_US.UTF-8&#39; may be necessary.<br>
<br>
The locale requested by LANG=en_US.utf8 isn&#39;t available here.<br>
Running `locale-gen en_US.utf8&#39; may be necessary.<br>
<br>
mosh-server needs a UTF-8 native locale to run.<br>
<br>
Unfortunately, the local environment (LANG=en_US.UTF-8) specifies<br>
the character set &quot;US-ASCII&quot;,<br>
<br>
The client-supplied environment (LANG=en_US.utf8) specifies<br>
the character set &quot;US-ASCII&quot;.<br>
<br>
locale: Cannot set LC_ALL to default locale: No such file or directory<br>
LANG=en_US.utf8<br>
LANGUAGE=<br>
LC_CTYPE=&quot;en_US.utf8&quot;<br>
LC_NUMERIC=&quot;en_US.utf8&quot;<br>
LC_TIME=en_DK.utf8<br>
LC_COLLATE=&quot;en_US.utf8&quot;<br>
LC_MONETARY=&quot;en_US.utf8&quot;<br>
LC_MESSAGES=&quot;en_US.utf8&quot;<br>
LC_PAPER=&quot;en_US.utf8&quot;<br>
LC_NAME=&quot;en_US.utf8&quot;<br>
LC_ADDRESS=&quot;en_US.utf8&quot;<br>
LC_TELEPHONE=&quot;en_US.utf8&quot;<br>
LC_MEASUREMENT=&quot;en_US.utf8&quot;<br>
LC_IDENTIFICATION=&quot;en_US.utf8&quot;<br>
LC_ALL=<br>
Connection to server closed.<br>
/usr/bin/mosh: Did not find mosh server startup message.<br>
ghigo@venice:~$<br>
<br>
<br>
If I do<br>
<br>
$ LC_TIME= mosh server<br>
ghigo@server&#39;s password:<br>
<br>
server$<br>
<br>
Everything is OK.<br>
<div><br>
<br>
<br>
&gt;<br>
&gt; I&#39;m guessing the &quot;right answer&quot; will involve building a locale on your<br>
&gt; client that matches something the server can do, but I&#39;ll defer judgment<br>
&gt; until I can see the diagnostic output.<br>
&gt;<br>
&gt; Best regards,<br>
&gt; Keith<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Dec 10, 2013 at 6:20 AM, Goffredo Baroncelli &lt;<a href="mailto:kreijack@libero.it" target="_blank">kreijack@libero.it</a><br>
</div><div><div>&gt; &lt;mailto:<a href="mailto:kreijack@libero.it" target="_blank">kreijack@libero.it</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi all,<br>
&gt;<br>
&gt;     I am facing the problem related to locale, when the host locale doesn&#39;t<br>
&gt;     match with the server locale.<br>
&gt;<br>
&gt;     The reason is that I have an uncommon setting of the environment<br>
&gt;     variable LC_TIME, which is set to en_DK.utf8 [1].<br>
&gt;<br>
&gt;     To avoid this problem I have to call mosh as below<br>
&gt;<br>
&gt;     LC_TIME= mosh &lt;server&gt;<br>
&gt;<br>
&gt;     and everything work properly.<br>
&gt;<br>
&gt;     Looking at the code, I noticed that in set_native_locale(), it is called<br>
&gt;     setlocale( LC_ALL, &quot;&quot; ).<br>
&gt;     Unfortunately this function fails even if *one* setting of the LC_*<br>
&gt;     doesn&#39;t match. This is what I saw.<br>
&gt;<br>
&gt;     However I suppose that mosh should care only about the LC_CTYPE setting.<br>
&gt;     If so, the following patch should narrow the cases where mosh fails when<br>
&gt;     the environments differ.<br>
&gt;<br>
&gt;     diff --git a/src/util/locale_utils.cc b/src/util/locale_utils.cc<br>
&gt;     index 11923ff..9e9eb0c 100644<br>
&gt;     --- a/src/util/locale_utils.cc<br>
&gt;     +++ b/src/util/locale_utils.cc<br>
&gt;     @@ -95,7 +95,7 @@ bool is_utf8_locale( void ) {<br>
&gt;<br>
&gt;      void set_native_locale( void ) {<br>
&gt;        /* Adopt native locale */<br>
&gt;     -  if ( NULL == setlocale( LC_ALL, &quot;&quot; ) ) {<br>
&gt;     +  if ( NULL == setlocale( LC_CTYPE, &quot;&quot; ) ) {<br>
&gt;          int saved_errno = errno;<br>
&gt;          if ( saved_errno == ENOENT ) {<br>
&gt;            LocaleVar ctype( get_ctype() );<br>
&gt;<br>
&gt;<br>
&gt;     In my case it works, but I don&#39;t know very well how mosh interact with<br>
&gt;     locale.<br>
&gt;<br>
&gt;     Comments ?<br>
&gt;<br>
&gt;     BR<br>
&gt;     G.Baroncelli<br>
&gt;<br>
&gt;     [1] For the record, I have this setting to see in thunderbird a &quot;date<br>
&gt;     which is readable.... but this is another story.<br>
&gt;<br>
&gt;     --<br>
</div></div>&gt;     gpg @<a href="http://keyserver.linux.it" target="_blank">keyserver.linux.it</a> &lt;<a href="http://keyserver.linux.it" target="_blank">http://keyserver.linux.it</a>&gt;: Goffredo<br>
<div>&gt;     Baroncelli (kreijackATinwind.it&gt;<br>
&gt;     Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5<br>
&gt;     _______________________________________________<br>
&gt;     mosh-devel mailing list<br>
</div>&gt;     <a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a> &lt;mailto:<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>&gt;<br>
&gt;     <a href="http://mailman.mit.edu/mailman/listinfo/mosh-devel" target="_blank">http://mailman.mit.edu/mailman/listinfo/mosh-devel</a><br>
<div><div>&gt;<br>
&gt;<br>
<br>
<br>
--<br>
gpg @<a href="http://keyserver.linux.it" target="_blank">keyserver.linux.it</a>: Goffredo Baroncelli (kreijackATinwind.it&gt;<br>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5<br>
</div></div></blockquote></div><br></div></div>