简体   繁体   English

C#-解码来自AS / 400 iSeries的数据

[英]C# - Decoding Data From an AS/400 iSeries

I am using the standard .NET OdbcConnection to connect to an AS/400 iSeries database. 我正在使用标准的.NET OdbcConnection连接到AS / 400 iSeries数据库。 I am able to query this database. 我可以查询该数据库。 Unfortunately, there are some fields that appear to be encoded. 不幸的是,有些字段似乎已编码。 How do I decode these values in C#? 如何在C#中解码这些值? I have tried the following: 我尝试了以下方法:

string text = string.Empty;
if (bytes.Length > 0)
{
    ASCIIEncoding encoder = new ASCIIEncoding();
    text = encoder.GetString(bytes);
}
return text;

The bytes variable represents the data that needs to be decoded. bytes变量表示需要解码的数据。 Unfortunately, I am not having any luck. 不幸的是,我没有任何运气。 I have been told that the data will return correctly if I setup an ODBC data source on my Windows machine and check the "Convert binary data (CCSID65535) to text" checkbox in the translation tab. 有人告诉我,如果在Windows计算机上设置ODBC数据源并选中转换选项卡中的“将二进制数据(CCSID65535)转换为文本”复选框,则数据将正确返回。 However, I want to use pure C#. 但是,我想使用纯C#。 Any ideas? 有任何想法吗? Am I way off? 我要走吗?

Thanks! 谢谢!

Chances are it's using EBCDIC. 它可能正在使用EBCDIC。 You could try using Encoding.GetEncoding(37) or you could use the EBCDIC encoding I wrote a while ago. 您可以尝试使用Encoding.GetEncoding(37),也可以使用我之前编写的EBCDIC编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM