-
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 some
helper functions to build the
translation table.
可能对文本文件的大型机中的数据进行编码,
EBCDIC
字符系统中。这不是直接由
VBA
,使用
ASCII
字符编码系统读取和写入文本文件时可用。
本文提供了两个的字符编码方案和一些
helper
函数,生成翻译表之间进行转换的函数。
Notes Regarding Character Sets
?
VBA supports
UNICODE, which is a superset of ASCII. Only
characters that fall into the
ASCII
range (Chr(0) to Chr(255)) will be translated.
?
The
translation tables supplied can be used to
translate a string of text from the U.S.
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 same 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-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
字符集
相同虽然较低的
128
个字符都相同。
?
因为有了
EBCDIC
和
ASCII
字符集中的几种变体尤其是对于国际的使用随意添加自定
义的转换表。
?
下面是
ASCII
到
EBCDIC
翻译为
HP
、
(为记录在
IBM 3780
手册)
,
IBM
和
AT &
T
某些显著的差异:
!
ASCII
HP EBCDIC
IBM EBCDIC
AT&T EBCDIC
21
4F
4A
5A
5F
5A
5B
5D
5E
5A
AD
BD
5F
[
5B
]
5D
^
5E
The major
difference is that 5A represents
differences not listed resolve
themselves in the range of non-printable
characters.
The functions
are:
?
主要区别是该
5A
表示
和
AT & T
,但
到。不列出其他不同解决本身中的
非打印字符范围。
这些函数是:
Function
Translate
Description
Converts a
string from one character encoding scheme to
another.
Requires a translation table
as one of the arguments.
ASCII_To_EBCDIC_Table
Returns a string containing the
translation table for converting an
ASCII string to an EBCDIC string.
EBCDIC_To_ASCII_Table
Returns a string containing the
translation table for converting an
EBCDIC string to an ASCII string.
HexToStr
A helper function
that converts a string of hexadecimal digits 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 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 I
Translate = Temp
-
-
-
-
-
-
-
-
-
上一篇:Letter of Authority 授权委托书
下一篇:与人有关的成语