EBCDIC码与ASCII码相互转换VBA_第1页
EBCDIC码与ASCII码相互转换VBA_第2页
EBCDIC码与ASCII码相互转换VBA_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、A text file of data from a mainframe computer may be encoded in the EBCDIC character system. This is not directly usable by VBA, which uses the ASCII character encoding system when reading and writing text files.This article provides a function to translate between two character encoding schemes and

2、 some helper functions to build the translation table. 可能对文本文件的大型机中的数据进行编码,EBCDIC 字符系统中。这不是直接由 VBA,使用 ASCII 字符编码系统读取和写入文本文件时可用。本文提供了两个的字符编码方案和一些 helper 函数,生成翻译表之间进行转换的函数。Notes Regarding Character SetsVBA supports UNICODE, which is a superset of ASCII. Only characters that fall into the ASCII range (

3、Chr(0) to Chr(255) will be translated. The translation tables supplied can be used to translate a string of text from the . English EBCDIC code page (CECP 037) character set to the ISO/ANSI ASCII character set and back again. The ISO/ANSI ASCII character set is used by Windows, but it is not the sam

4、e as the IBM PC OEM ASCII character set, although the lower 128 characters are identical. Because there are several variations of both the EBCDIC and ASCII character sets, especially for international use, feel free to add customized translation tables. Here are some notable differences in the ASCII

5、-to-EBCDIC translation for HP, IBM (as documented in the IBM 3780 manual), and AT&T:有关字符集的笔记VBA 支持 UNICODE,是 ASCII 的一个超集。只有属于 (将转换为 Chr(255) Chr(0) ASCII 范围的字符 提供的转换表可用于翻译的美国英语 EBCDIC 代码页 (CECP 037) 字符集中的文本,以 ISO/ANSI ASCII 字符集字符串和反向切换。 ISO/ANSI ASCII 字符集使用的 Windows,但不是与 IBM 的 PC OEM ASCII 字符集相同虽然较低

6、的 128 个字符都相同。 因为有了 EBCDIC 和 ASCII 字符集中的几种变体尤其是对于国际的使用随意添加自定义的转换表。 下面是 ASCII 到 EBCDIC 翻译为 HP、 (为记录在 IBM 3780 手册),IBM 和 AT & T 某些显着的差异:ASCIIHP EBCDICIBM EBCDICAT&T EBCDIC!214F5A5A5B4A5BAD5D5A5DBD5E5F5E5FThe major difference is that 5A represents ! to IBM and AT&T, but to HP. Other differences not list

7、ed resolve themselves in the range of non-printable characters. The functions are:主要区别是该 5A 表示!IBM 和 AT & T,但HP 到。不列出其他不同解决本身中的非打印字符范围。 这些函数是:FunctionDescriptionTranslateConverts a string from one character encoding scheme to another. Requires a translation table as one of the arguments.ASCII_To_EBC

8、DIC_TableReturns a string containing the translation table for converting an ASCII string to an EBCDIC string.EBCDIC_To_ASCII_TableReturns a string containing the translation table for converting an EBCDIC string to an ASCII string.HexToStrA helper function that converts a string of hexadecimal digi

9、ts into the actual characters they represent.The function source is as follows. The code can be pasted into any VBA Module:函数源如下所示。可将代码粘贴到任何 VBA 模块中:Function Translate(ByVal InText As String, xlatTable As String) As String Uses a translation table to map InText from one character set to another.Dim

10、Temp As String, I As Long Temp = Space$(Len(InText)For I = 1 To Len(InText)Mid$(Temp, I, 1) = Mid$(xlatTable, Asc(Mid$(InText, I, 1) + 1, 1) Next ITranslate = TempEnd FunctionFunction ASCII_To_EBCDIC_Table() As String Returns the following table as a string for use by the Translate function to trans

11、late an EBCDIC string to an ASCII-ISO/ANSI string. 00 01 02 03 37 2D 2E 2F 16 05 25 0B 0C 0D 0E 0F 10 11 12 13 3C 3D 32 26 18 19 3F 27 1C 1D 1E 1F 40 5A 7F 7B 5B 6C 50 7D 4D 5D 5C 4E 6B 60 4B 61 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 7A 5E 4C 7E 6E 6F 7C C1 C2 C3 C4 C5 C6 C7 C8 C9 D1 D2 D3 D4 D5 D6 D7 D8 D9

12、E2 E3 E4 E5 E6 E7 E8 E9 AD E0 BD 5F 6D 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 97 98 99 A2 A3 A4 A5 A6 A7 A8 A9 C0 4F D0 A1 07 20 21 22 23 24 15 06 17 28 29 2A 2B 2C 09 0A 1B 30 31 1A 33 34 35 36 08 38 39 3A 3B 04 14 3E E1 41 42 43 44 45 46 47 48 49 51 52 53 54 55 56 57 58 59 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 8A 8B 8C 8D 8E 8F 90 9A 9B 9C 9D 9E 9F A0 AA AB AC 4A AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC 6A BE BF CA CB CC CD CE CF DA dB DC DD DE DF EA EB EC ED EE EF FA FB FC FD FE FFASCII_To_EBCDIC_Table = _HexToStr(000D2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论