Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

robin.k

I just figured it out. Thanks for your help martin, the session log lead me to right google searches. :)
My powershell script was encoded in UTF8, after reencoding it in UTF8-BOM (with Notepad++) the parameters are passed correctly, and the download works as intended.
martin

Please attach WinSCP session log file both from PowerShell and GUI.

Though chances are that GUI was able to autodetect that the server fails to use UTF-8 encoding for files, while GUI is retrieving an initial directory listing. But .NET assembly does do any initial listing (unless you ask for it).
See https://winscp.net/eng/docs/faq_utf8#sftp
robin.k

Yes, the GUI works without a problem.
WinSCP Version: 5.13.5
martin

Re: Powershell UTF8 paths in GetFiles

Can you download those files in WinSCP GUI?
robin.k

Powershell UTF8 paths in GetFiles

Hello,
I'm using the example from https://winscp.net/eng/docs/library_session_getfiles in a powershell script to download files from a sftp server.
It works fine if the paths used in GetFiles() don't contain anything else than ASCII characters. If I create a directory on the server that contains german umlauts or chinese Han characters, I get a "No such file or directory" error.

Error with umlaut:
Error: Error listing directory '/Aufträge'.

No such file or directory.
Error code: 2
Error message from server: No such file


Error with han character:
Error: Error listing directory '/ä»S'.

No such file or directory.
Error code: 2
Error message from server: No such file


GetFiles Call:
$transferResult = $session.GetFiles("/Aufträge/*", "D:\Aufträge\", $False, $transferOptions)

It does neither work with source nor with destination path.
It looks like the strings are converted to ascii at some point. Does anyone know how to use UTF8 paths in powershell?