文件编码 (Visual Basic)File Encodings (Visual Basic)

文件编码也称为字符编码,用于指定在处理文本时如何表示字符。File encodings, also known as character encodings, specify how to represent characters when text processing. 虽然 Unicode 是最常用的编码,但根据编码能否处理某种语言字符,另一种编码可能更优。One encoding may be preferable over another in terms of which language characters it can or cannot handle, although Unicode is usually preferred.

读取或写入文件时,未正确匹配文件编码可能会导致发生异常或产生不正确的结果。When reading from or writing to files, improperly matching file encodings may result in exceptions or incorrect results.

编码类型Types of Encodings

处理文件时,Unicode 是首选编码。Unicode is the preferred encoding when working with files. Unicode 是全球范围的字符编码标准,使用 16 位代码值来表示现代计算中使用的所有字符,包括印刷中使用的技术符号和特殊字符。Unicode is a worldwide character-encoding standard that uses 16-bit code values to represent all the characters used in modern computing, including technical symbols and special characters used in publishing.

以前的字符编码标准包括传统的字符集,如 Windows ANSI 字符集,该字符集使用 8 位代码值或 8 位值组合来表示特定语言或地理区域中使用的字符。Previous character-encoding standards consisted of traditional character sets, such as the Windows ANSI character set that uses 8-bit code values, or combinations of 8-bit values, to represent the characters used in a specific language or geographical region.

编码类Encoding Class

Encoding 类表示字符编码。The Encoding class represents a character encoding. 下表列出并描述了每个可用的编码类型。This table lists the type of encodings available and describes each.

名称Name 说明Description
ASCIIEncoding 表示 Unicode 字符的 ASCII 字符编码。Represents an ASCII character encoding of Unicode characters.
UnicodeEncoding 表示 Unicode 字符的 UTF-16 编码。Represents a UTF-16 encoding of Unicode characters.
UTF32Encoding 表示 Unicode 字符的 UTF-32 编码。Represents a UTF-32 encoding of Unicode characters.
UTF7Encoding 表示 Unicode 字符的 UTF-7 编码。Represents a UTF-7 encoding of Unicode characters.
UTF8Encoding 表示 Unicode 字符的 UTF-8 编码。Represents a UTF-8 encoding of Unicode characters.

另请参阅See also