Escribiendo una cadena ANSI en un archivo Unicode a través de FTP
Tengo la siguiente función de Visual Basic 6.0 que escribe una cadena ANSI en un nuevo archivo a través de FTP. Me gustaría que escribiera el archivo como UTF-16LE. ¿Hay alguna buena manera de hacerlo dentro de este método siguiente?
Public Sub writeToFile(ByVal FTPServer As String _
, ByVal userName As String _
, ByVal password As String _
, ByVal contents As String _
, ByVal destinationFile As String)
Dim hFile As Long
Dim lCount As Long
inetOpen
inetConnect FTPServer, userName, password
hFile = apiFtpOpenFile(m_hFTP, destinationFile, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0&)
If hFile = 0 Then
Err.Raise EWMFTPErrorCodes.wmFTPSendError, , internetError
End If
If apiInternetWriteFile(hFile, contents, Len(contents), lCount) = 0 Then
Err.Raise EWMFTPErrorCodes.wmFTPSendError, , internetError
End If
apiInternetCloseHandle hFile
End Sub
No he hecho Visual Basic 6.0 en unos 10 años, por lo que soy inestable en el mejor de los casos. Cualquier contribución será muy apreciada
Aquí está la declaración apiInternetWriteFile;
Private Declare Function apiInternetWriteFile Lib "wininet.dll" Alias "InternetWriteFile" ( _
ByVal hFile As Long _
, ByVal lpBuffer As String _
, ByVal dwNumberOfBytesToWrite As Long _
, ByRef lpdwNumberOfBytesWritten As Long) As Long