我正在通过 FTP 将文件从 AS/400 传输到我们的 Windows (SBS 2003)。这些文件是固定宽度的数据。文本看起来不错,但有些字段是压缩小数,解压缩时会给出错误的值。我的假设是发生了隐式 EBCDIC->ASCII 转换,它也在转换打包字节。但是,进行反向转换并解包它们仍然会给出错误的值......有时。
我的猜测是他们使用的代码页略有不同(所以当我转换回 EBCDIC 时,它并不完全相同),但我不知道如何找出他们正在使用的代码页(他们的 IT 人员正在.. .轻度顽固...否则他们可以只以二进制模式执行FTP并跳过所有这些问题)。
这是一些示例数据 - 这些应该解压缩为 8 位数字,这些数字实际上是 YYYYMMDD 格式的日期。
Received:
2,0,216,202,164
2,0,144,22,177
2,0,16,176,172
2,0,16,176,172
2,0,16,176,172
2,0,16,176,172
1,114,176,160,124
2,0,248,32,63
2,0,144,226,164
2,0,144,226,164
2,0,144,226,164
2,0,144,202,124
2,0,144,202,124
2,0,144,176,172
2,0,144,176,172
2,0,32,22,63
2,0,38,248,172
2,0,38,248,172
2,0,38,98,164
2,0,233,1,15
2,0,45,107,172
1,114,176,226,26
1,114,176,38,177
1,114,176,97,164
2,0,0,17,124
2,0,128,129,31
2,0,128,129,31
2,0,128,129,31
2,0,128,129,31
2,0,128,129,31
2,0,128,129,31
2,0,216,17,63
2,0,160,17,31
2,0,160,128,34
2,0,160,129,26
2,0,38,128,31
2,0,38,144,26
1,114,97,16,124
1,114,97,16,124
2,0,38,234,26
2,0,38,201,172
2,0,45,38,124
2,0,45,216,164
2,0,45,107,177
2,0,248,234,124
2,0,248,202,34
2,0,248,18,172
2,0,97,128,172
2,0,248,18,7
2,0,248,233,15
2,0,201,2,15
2,0,176,16,7
2,0,106,0,31
2,0,216,22,34
2,0,216,160,63
2,0,38,107,7
2,0,233,0,63
2,0,38,107,164
2,0,233,0,26
2,0,38,107,34
2,0,233,0,164
2,0,233,17,15
2,0,45,202,177
2,0,45,106,7
2,0,45,97,177
2,0,47,16,31
2,0,248,216,177
2,0,201,0,172
2,0,176,201,63
2,0,248,97,34
2,0,176,202,26
2,0,248,97,34
2,0,201,2,172
2,0,201,17,164
2,0,176,129,164
2,0,201,17,172
2,0,176,144,7
2,0,145,2,164
2,0,32,145,15
2,0,38,45,26
2,0,38,38,63
2,0,38,233,26
2,0,38,248,34
2,0,45,202,164
2,0,45,107,124
2,0,47,17,15
2,0,47,16,31
2,0,47,130,34
2,0,248,45,177
2,0,106,0,31
2,0,248,22,31
2,0,248,202,172
2,0,248,97,172
2,0,47,128,177
2,0,201,2,164
2,0,216,201,164
2,0,176,16,34
2,0,216,201,34
这是转换回 ebcdic 的代码页,但它不是很有效:
ascii = Array( _
&H0, &H1, &H2, &H3, &H37, &H2D, &H2E, &H2F, &H16, &H5, &H25, &HB, &HC, &HD, &HE, &HF, _
&H10, &H11, &H12, &H13, &H3C, &H3D, &H32, &H26, &H18, &H19, &H3F, &H27, &H1C, &H1D, &H1E, &H1F, _
&H40, &H4F, &H7F, &H7B, &H5B, &H6C, &H50, &H7D, &H4D, &H5D, &H5C, &H4E, &H6B, &H60, &H4B, &H61, _
&HF0, &HF1, &HF2, &HF3, &HF4, &HF5, &HF6, &HF7, &HF8, &HF9, &H7A, &H5E, &H4C, &H7E, &H6E, &H6F, _
&H7C, &HC1, &HC2, &HC3, &HC4, &HC5, &HC6, &HC7, &HC8, &HC9, &HD1, &HD2, &HD3, &HD4, &HD5, &HD6, _
&HD7, &HD8, &HD9, &HE2, &HE3, &HE4, &HE5, &HE6, &HE7, &HE8, &HE9, &H4A, &HE0, &H5A, &H5F, &H6D, _
&H79, &H81, &H82, &H83, &H84, &H85, &H86, &H87, &H88, &H89, &H91, &H92, &H93, &H94, &H95, &H96, _
&H97, &H98, &H99, &HA2, &HA3, &HA4, &HA5, &HA6, &HA7, &HA8, &HA9, &HC0, &H6A, &HD0, &HA1, &H7, _
&H20, &H21, &H22, &H23, &H24, &H15, &H6, &H17, &H28, &H29, &H2A, &H2B, &H2C, &H9, &HA, &H1B, _
&H30, &H31, &H1A, &H33, &H34, &H35, &H36, &H8, &H38, &H39, &H3A, &H3B, &H4, &H14, &H3E, &HE1, _
&H41, &H42, &H43, &H44, &H45, &H46, &H47, &H48, &H49, &H51, &H52, &H53, &H54, &H55, &H56, &H57, _
&H58, &H59, &H62, &H63, &H64, &H65, &H66, &H67, &H68, &H69, &H70, &H71, &H72, &H73, &H74, &H75, _
&H76, &H77, &H78, &H80, &H8A, &H8B, &H8C, &H8D, &H8E, &H8F, &H90, &H9A, &H9B, &H9C, &H9D, &H9E, _
&H9F, &HA0, &HAA, &HAB, &HAC, &HAD, &HAE, &HAF, &HB0, &HB1, &HB2, &HB3, &HB4, &HB5, &HB6, &HB7, _
&HB8, &HB9, &HBA, &HBB, &HBC, &HBD, &HBE, &HBF, &HCA, &HCB, &HCC, &HCD, &HCE, &HCF, &HDA, &HDB, _
&HDC, &HDD, &HDE, &HDF, &HEA, &HEB, &HEC, &HED, &HEE, &HEF, &HFA, &HFB, &HFC, &HFD, &HFE, &HFF)