对文本文件进行编码以显示在 IBM 大型机上

发布于 2024-10-27 11:17:38 字数 297 浏览 5 评论 0原文

我有一个 C++ 程序,它通过 ASCII 模式通过 FTP 将数据发送到 IBM 大型机。我现在通过 C# 执行此操作。

当它到达那里并查看该文件时,该文件看起来像垃圾。

我在 C++ 代码中看不到任何可以将文件编码为 EPCDIC 等特殊内容的内容。当发送 C++ 文件时,它们可以正常查看。我看到的唯一不同的是 \015 & \012 表示换行,而 C# 使用 \r\n。

这些字符会产生影响吗?如果是的话,我怎样才能让我的 C# 应用程序使用 \015?

我是否需要进行任何特殊编码才能使其显示正常?

I have a C++ program that sends data via FTP via ASCII mode to an IBM Mainframe. I am now doing this via C#.

When it gets there and viewed the file looks like garbage.

I cannot see anything in the C++ code that does anything special to encode the file into something like EPCDIC. When the C++ files are sent they are viewed ok. The only thing I see different is \015 & \012 for line feeds whereas C# is using \r\n.

Would these characters have an effect and if so how can I get my C# app to use \015?

Do I have to do any special encoding to make it appear ok?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谜兔 2024-11-03 11:17:38

听起来您确实应该使用 EBCDIC 编码,然后可能以二进制形式传输文本。如果您愿意,我有一个 EBCDIC 编码类 您可以使用。

请注意,\015\012 \r\n - 它们是十进制的字符 13 和 10,只是表示它们的方式不同。如果您认为 C++ 代码确实生成与 C# 相同的文件,请在二进制文件编辑器中比较两个应该相同的文件。

It sounds like you should indeed be using an EBCDIC encoding, and then probably transferring the text in binary. I have an EBCDIC encoding class you can use, should you wish.

Note that \015\012 is \r\n - they're characters 13 and 10 in decimal, just different ways of representing them. If you think the C++ code really is producing the same files as C#, compare two files which should be the same in a binary file editor.

从﹋此江山别 2024-11-03 11:17:38

在传输文件之前,请确保您使用的是 TYPE TEXT 而不是 TYPE BINARY 命令。

Make sure you have the TYPE TEXT instead of TYPE BINARY command before you transfer the file.

泛泛之交 2024-11-03 11:17:38

如果您确实以 ASCII 模式发送文件,那么大型机本身会将其转换为 EBCDIC(接收方会做好)。

事实上,您在大型机端得到了明显的垃圾,并且字符代码 \015\012 (分别是 CRLF)意味着您以 ASCII 模式传输。

顺便说一句,ISPF 编辑器现在已经能够查看相当多版本的 ASCII 数据集。打开文件并输入命令 source asciilf

第一个渲染将字符从 ASCII 转换为 EBCDIC,以便您可以看到它们是什么,第二个渲染将遍历并填充“行”,以便用足够的空格替换换行标记以达到记录长度。

在处理混合编码环境时,这是非常宝贵的命令,这是我做很多工作的地方。

If you are truly sending the files in ASCII mode, then the mainframe itself will convert that to EBCDIC (it's receiver-makes-good).

The fact that you're getting apparent garbage at the mainframe end, and character codes \015 and \012 (which are CR and LF respectively) means that you're not transferring in ASCII mode.

As an aside, the ISPF editor has been able to view ASCII data sets for quite a few versions now. Open up the file and enter the commands source ascii and lf.

The first renders converts the characters from ASCII to EBCDIC so you can see what they are, the second goes through and pads out "lines" so that linefeed markers are replaced with enough spaces to reach the record length.

Invaluable commands when dealing with mixed-encoding environments, which is where I do a lot of my work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文