Problem with German umlauts when using multiple tasks to perform a download operation

Advertisement

OguzhanO
Guest

Problem with German umlauts when using multiple tasks to perform a download operation

Hello WinSCP-Team,

I've been facing an issue with german umlauts when using multiple tasks in C#. The WinSCP Session Class told me that a file/folder (with an umlaut) wouldn't exist (but it actually did).
So I have been trying around with the WinSCP client itself and activated the debug log write mode (to see what happens behind the scene). The file/folder with the umlaut existed and I could navigate into the folder and download the file inside the WinSCP client, as expected. However, the log told me that the file/folder was not found but later then successfully accessed to the resource (like it fixed the problem itself).
The interesting thing is: this happens only when I'm trying to use multiple tasks. Using a single session instance to perform a download operation works perfectly fine.
The FTP-server supports UTF8.

The error code I get is 2 (ERROR_FILE_NOT_FOUND from GetLastError).

Things I've ensured/tried:
- Programmatically set the encoding to UTF8
- Tried to encode the folder/file name I want to access to
- Programmatically enabled the logs to make some checks
- Programmatically enabled the default configuration (/ini=nul)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,567
Location:
Prague, Czechia

Re: Problem with German umlauts when using multiple tasks to perform a download operation

Please attach commented log files for all your tests (GUI, single session instance, multiple tasks).

Reply with quote

Guest

Re: Problem with German umlauts when using multiple tasks to perform a download operation

martin wrote:

Please attach commented log files for all your tests (GUI, single session instance, multiple tasks).

Since there are few sensitive information inside the log file, I cannot just upload it yet. I will run few tests at home and upload it then. Bookmark this thread and check it tomorow again, please.

Reply with quote

Advertisement

OguzhanO
Guest

My SFTP server uses an old version which transfers directory listings with the encoding 1252. WinSCP guesses the encoding when the switch ("Utf8") is set to 2.
My problem was that the first session calls ListDirectory and the directory listing contained a german umlaut. So WinSCP guessed that the server encodes filenames with 1252 instead of utf8. When I used this session to download files, everything was working correctly because WinSCP sent the requested filenames encoded with 1252.
But then I converted my code to the multithreaded variant from https://winscp.net/eng/docs/library_example_parallel_transfers and the download didn't work anymore, because the tasks create new sessions which don't know about the encoding. They assume that the server uses utf8 and send the requested file paths as utf8. The server decodes the paths as 1252 and replies that the files don't exist.
My workaround is to call ListDirectory for a directory with umlauts in file names for each new session (after opening the connection to the server), so that the session switches to encoding 1252.

Reply with quote

Advertisement

You can post new topics in this forum