Note that there are some explanatory texts on larger screens.

plurals
  1. POWinAPI FTPGetFile Conversion From ANSI to Unicode
    primarykey
    data
    text
    <p>Premise: Copying files from Linux to Windows over FTP using WinInet FtpGetFile.</p> <p>Objective: The files originate as ANSI and are needed in Unicode.</p> <p>Progress: The only issue I am having is that I need LF characters from the original file to be CRLF characters in the destination file. <br> I have tried:</p> <pre><code>Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileW" (ByVal hFTP As Long, ByVal sRemoteFile As String, ByVal sNewFile As String, ByVal bFailIfExists As Boolean, ByVal lFlagsAndAttributes As Long, ByVal lFlags As Long, ByVal lContext As Long) As Boolean Public Sub test(hConn as Long, strSrcPath as String, strDestPath as String) 'All code works other than the file not converting to having CR chars ftpGetFile(hConn, StrConv(strSrcPath, vbUnicode), StrConv(strDestPath, vbUnicode), True, 0, 0, 0) End Sub </code></pre> <ul> <li>(FAILS to convert) using the Unicode version of the <code>FtpGetFile</code> method (<code>Alias FtpGetFileW</code>), passing the arguments using <code>StrConv(&lt;string&gt;, vbUnicode)</code>. The files show up with only LF chars at the end of the lines.</li> <li>(WORKS, manually) copying files manually using WinSCP. It automatically makes the output files Unicode but I can't find the method/settings associated with this. I cannot use the WinSCP.dll at my work as I cannot register it.</li> <li>(WORKS, slowly) using a work-around. using the either version of the <code>FtpGetFile</code>. Opening file, reading to variable, closing file and then opening file for write, writing <code>Replace(variable,Chr(10),Chr(13)&amp;Chr(10))</code>. Also, files appear to ~double in size.</li> </ul> <p>How do I get a file using the WinAPI functions and have it convert in one shot (if possible)? </p> <p>Related articles:<br> <a href="https://stackoverflow.com/questions/5483625/unicode-turns-ansi-after-ftp-transfer">Unicode turns ANSI after FTP transfer</a> <br> <a href="https://stackoverflow.com/questions/5496110/writing-ansi-string-to-unicode-file-over-ftp">Writing ANSI string to Unicode file over FTP</a></p> <p>Source Info:<br> <a href="http://www.codeguru.com/vb/vb_internet/article.php/c19511/Creating-an-FTP-Component-in-Visual-Basic.htm" rel="nofollow noreferrer">How to Create FTP Components CodeGuru</a><br> <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa385483(v=vs.85).aspx" rel="nofollow noreferrer">MSDN for WinInet</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload