Subject: RE: SFTP character encoding and problem with agent auth

RE: SFTP character encoding and problem with agent auth

From: Željko Marjanović <>
Date: Fri, 13 Aug 2010 21:37:40 +0200

Thank you for your detailed reply. Much appreciated :-)

I will code the components as you suggested, use the UTF-8
as the default encoding and let the users choose alternate
encodings if they wish so.

I had another idea how to get the encoding the server is using, dunno if it's good enough :-)
The idea was to open the ssh channel and read the LANG/LC_ALL env variables if they exist,
parse them and set the encoding; if they don’t exist revert to default.

This will have to wait, cause I'm on vacation right now, and before that I need to port
the port forwarding part completely :-)

Best regards,

-----Original Message-----
From: [] On Behalf Of Alexander Lamaison
Sent: Thursday, August 12, 2010 12:21 AM
To: libssh2 development
Subject: Re: SFTP character encoding and problem with agent auth

On 11 August 2010 23:15, Alexander Lamaison <> wrote:
> 2010/8/11 Željko Marjanović <>:
>> Is it possible to determine the character encoding the SSH/SFTP
>> server is using? I have read the protocol specs for SFTP v3 and there
>> is no mention of it, but in v4 default encoding is UTF-8. Is it safe
>> to assume and use UTF-8 for default encoding?
> I have no idea how SFTP v4 expects servers to guarantee they supply
> UTF-8 when the server doesn't even know the encoding of its own
> filenames!

Lo and behold, this is what the SFTP v6 spec says [1]:

   The preferred encoding for filenames is UTF-8. This is consistent
   with IETF Policy on Character Sets and Languages [RFC2277] and it is
   further supposed that the server is more likely to support any local
   character set and be able to convert it to UTF-8.

   However, because the server does not always know the encoding of
   filenames, it is not always possible for the server to preform a
   valid translation to UTF-8. When an invalid translation to UTF-8 is
   preformed, it becomes impossible to manipulate the file, because the
   translation is not reversible. ...



Swish - Easy SFTP for Windows Explorer ( _______________________________________________
Received on 2010-08-13