[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FTPAPI & text file transfers
Sender: Christian <chrisv5@xxxxxx>
hello all,
today I started using FTPLIB for the first time and I made an
observation which I like to share with everyone (even suggest adding to
the "documentation".
I am writing a generic utility to transfer arbitrary text files (mainly
EDI docs & HTML/CSS/JavaScript docs, XML docs) from any FTP server
to/from the IFS on the iSeries (oops, System i). As others have found,
if one uses ftp_binaryMode(sessionID: *ON) then the nice ASCII (or
Latin-1, etc.) files in the IFS get garbled on the FTP server (PUT), or
one ends up with rubbish in the IFS (GET). It has been suggested in the
past to use ftp_binaryMode(SessionID: *OFF) in that case.
Well, not only does this strike me odd, to send ASCII files as BINARY,
it is also quite wrong! It has worked for you guys who GET/PUT files
from/to Windows FTP servers, but what happens if you send them to UNIX
style FTP servers? Right, no CRLF to LF transformations occur, which is
VERY BAD. Same goes for Mac files, which have lines terminated by CR only.
The proper way to do it is the following:
callp ftp_binaryMode(ftp: *off)
callp ftp_codePage(ftp: 00819: 00819)
This way the line breaks at the server (CRLF or LF or CR) get converted
to/from CRLF in the IFS files rather nicely while no code page
conversion occurs. The only downside is the pretty unnecessary
conversion from one code page to the same (not sure if the iconv API is
smart enough to take a short cut).
Of course, one may feel free to use different code pages, but 00819 is
fine for most Western countries. If you need the € in a PC file, you
better use 01252. Of course, feel free to use UTF-8 (as long as you are
on V5R3 at the minimum, iirc) as well, for those dealing mainly with
Linux and/or XML files.
I hope this was helpful to someone.
Regards,
Christian
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------