+1 vote
by (170 points)
edited by

Applies to: Rebex SFTP

1 Answer

+2 votes
by (150k points)
selected by
 
Best answer

var client = new Sftp();
client.Encoding = EncodingTools.GetEncoding("windows-1252")
client.Connect(...);
client.Login(...);

var client = new Sftp();
client.LogWriter = new Rebex.FileLogWriter("rebexlog.txt", Rebex.LogLevel.Debug); 
client.Encoding = Encoding.UTF8;
client.Connect(...);
client.Login(...);
client.ChangeDirectory(...); // change the directory to the one containing the files with umlauts
string[] items = client.GetRawList(); // get a listing of that directory

by (750 points)
Makes sense: the server is configured to use UTF-8, so it cannot understand umlaute, when the client uses 1252 encoding or vice versa.

Regards
by (150k points)
Rebex SFTP still default to non-UTF-8 encodings with many SFTP v3 servers. This is mostly a legacy from early 2000s where UTF-8 was not as ubiquitous as it is now. I guess we'll switch to using UTF-8 by default in 2021. Thanks for bringing this to our attention!
by (170 points)
Thank you so much!
Changing the encoding to utf-8 before connecting to the server worked with this line of code :
sftp.Encoding = System.Text.Encoding.UTF8;
by (150k points)
Starting with Rebex SFTP R6.0, we use UTF-8 by default.
https://www.rebex.net/sftp.net/history.aspx#R6.0
...