views:

323

answers:

4

I have a client running an AS/400. I have to ftp a flat file over to them. They tell me their return charaters are RN. I don't recognize this, could not find anything on it, and their tech guy is Nick Burns so he refuses to give me any dirtection. Is there a standard return code for AS/400?

I should have mentioned that I have a c# .NET 2.0 console application.

A: 

\r\n

CRLF

Carridge return followd by a Line feed

Midhat
And everyone beware of Nick Burns
Midhat
but, do I just add this as a string to the end of the line?
donde
+2  A: 

Perhaps they mean \r\n?

ChrisBD
+5  A: 

The AS/400 uses EBCDIC as a character set, rather than either the DOS or Unix ASCII character set. In Unix, text file lines typically end with ASCII '\n' and in DOS lines typically end with ASCII '\r\n'.

When you FTP, if you use the EBCDIC transfer type, rather than bin or ASCII; ftp is supposed to translate these characters for you.

EBCDIC carriage-return is 0x0D, just like ASCII.
EBCDIC line-feed is 0x25, unlike ASCII 0x0A.

AS/400 EBCDIC new-line has 0x15 - NEL (NExt Line").

For more information on end-of-line termination, see this Wikipedia article.

Heath Hunnicutt
+1 nice, complete answer
BlueRaja - Danny Pflughoeft
Despite the Wikipedia article, I am not convinced that NEL is a commonly used AS/400 newline character. We've always used CR and LF characters on the AS/400 when communicating with other machines.
John Y
I should add that we've also never stored newlines *within* a field, except specifically for data that is eventually destined for an outside machine, not for use on the AS/400 itself. And of course, in those situations we would use LF or CRLF, not NEL.
John Y
Is the LF you use 0x25 or 0x0A?
Heath Hunnicutt
If the rest of the data is EBCDIC and I'm relying on a separate translation step (as you say, FTP *should* do this), I leave it as 0x25. However, I do sometimes prepare ASCII data on the AS/400, in which case it will be 0x0A.
John Y
A: 

Since you mention you are using C#, simply use Environment.NewLine and don't worry about it :)

BlueRaja - Danny Pflughoeft
I was doing that for my local tests, but thought it I did for the ftp file, it would send the .NET carraige return over to AS/400 and would fails since they are both diff "Environments".
donde
There is no ".Net carriage return" - .Net uses the carriage return for whatever system you're running. As for FTP: If you are using the correct transfer type (EBCDIC, as mentioned by Heath above), it will translate the return-characters for you between different systems.
BlueRaja - Danny Pflughoeft