UTF32Encoding 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 Unicode 字符的 UTF-32 编码。
public ref class UTF32Encoding sealed : System::Text::Encoding
public sealed class UTF32Encoding : System.Text.Encoding
[System.Serializable]
public sealed class UTF32Encoding : System.Text.Encoding
type UTF32Encoding = class
inherit Encoding
[<System.Serializable>]
type UTF32Encoding = class
inherit Encoding
Public NotInheritable Class UTF32Encoding
Inherits Encoding
- 继承
- 属性
示例
以下示例演示了启用了错误检测的对象的行为 UTF32Encoding 。 它创建一个字节数组,其最后四个字节表示无效的代理项对;高代理项 U+D8FF 后跟 U+01FF,它超出了低代理项的范围(0xDC00到0xDFFF)。 如果没有错误检测,UTF32 解码器使用替换回退将无效代理项对替换为 REPLACEMENT CHARACTER(U+FFFD)。
using System;
using System.Text;
public class Example
{
public static void Main()
{
// Create a UTF32Encoding object with error detection enabled.
var encExc = new UTF32Encoding(! BitConverter.IsLittleEndian, true, true);
// Create a UTF32Encoding object with error detection disabled.
var encRepl = new UTF32Encoding(! BitConverter.IsLittleEndian, true, false);
// Create a byte arrays from a string, and add an invalid surrogate pair, as follows.
// Latin Small Letter Z (U+007A)
// Latin Small Letter A (U+0061)
// Combining Breve (U+0306)
// Latin Small Letter AE With Acute (U+01FD)
// Greek Small Letter Beta (U+03B2)
// a high-surrogate value (U+D8FF)
// an invalid low surrogate (U+01FF)
String s = "za\u0306\u01FD\u03B2";
// Encode the string using little-endian byte order.
int index = encExc.GetByteCount(s);
Byte[] bytes = new Byte[index + 4];
encExc.GetBytes(s, 0, s.Length, bytes, 0);
bytes[index] = 0xFF;
bytes[index + 1] = 0xD8;
bytes[index + 2] = 0xFF;
bytes[index + 3] = 0x01;
// Decode the byte array with error detection.
Console.WriteLine("Decoding with error detection:");
PrintDecodedString(bytes, encExc);
// Decode the byte array without error detection.
Console.WriteLine("Decoding without error detection:");
PrintDecodedString(bytes, encRepl);
}
// Decode the bytes and display the string.
public static void PrintDecodedString(Byte[] bytes, Encoding enc)
{
try {
Console.WriteLine(" Decoded string: {0}", enc.GetString(bytes, 0, bytes.Length));
}
catch (DecoderFallbackException e) {
Console.WriteLine(e.ToString());
}
Console.WriteLine();
}
}
// The example displays the following output:
// Decoding with error detection:
// System.Text.DecoderFallbackException: Unable to translate bytes [FF][D8][FF][01] at index
// 20 from specified code page to Unicode.
// at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
// at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index
// )
// at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
// at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDeco
// der)
// at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
// at Example.PrintDecodedString(Byte[] bytes, Encoding enc)
//
// Decoding without error detection:
// Decoded string: zăǽβ�
Imports System.Text
Public Module Example
Public Sub Main()
' Create a UTF32Encoding object with error detection enabled.
Dim encExc As New UTF32Encoding(Not BitConverter.IsLittleEndian, True, True)
' Create a UTF32Encoding object with error detection disabled.
Dim encRepl As New UTF32Encoding(Not BitConverter.IsLittleEndian, True, False)
' Create a byte arrays from a string, and add an invalid surrogate pair, as follows.
' Latin Small Letter Z (U+007A)
' Latin Small Letter A (U+0061)
' Combining Breve (U+0306)
' Latin Small Letter AE With Acute (U+01FD)
' Greek Small Letter Beta (U+03B2)
' a high-surrogate value (U+D8FF)
' an invalid low surrogate (U+01FF)
Dim s As String = "za" & ChrW(&H0306) & ChrW(&H01FD) & ChrW(&H03B2)
' Encode the string using little-endian byte order.
Dim index As Integer = encExc.GetBytecount(s)
Dim bytes(index + 3) As Byte
encExc.GetBytes(s, 0, s.Length, bytes, 0)
bytes(index) = &hFF
bytes(index + 1) = &hD8
bytes(index + 2) = &hFF
bytes(index + 3) = &h01
' Decode the byte array with error detection.
Console.WriteLine("Decoding with error detection:")
PrintDecodedString(bytes, encExc)
' Decode the byte array without error detection.
Console.WriteLine("Decoding without error detection:")
PrintDecodedString(bytes, encRepl)
End Sub
' Decode the bytes and display the string.
Public Sub PrintDecodedString(bytes() As Byte, enc As Encoding)
Try
Console.WriteLine(" Decoded string: {0}", enc.GetString(bytes, 0, bytes.Length))
Catch e As DecoderFallbackException
Console.WriteLine(e.ToString())
End Try
Console.WriteLine()
End Sub
End Module
' The example displays the following output:
' Decoding with error detection:
' System.Text.DecoderFallbackException: Unable to translate bytes [FF][D8][FF][01] at index
' 20 from specified code page to Unicode.
' at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
' at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index
' )
' at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
' at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDeco
' der)
' at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
' at Example.PrintDecodedString(Byte[] bytes, Encoding enc)
'
' Decoding without error detection:
' Decoded string: zăǽβ�
以下示例使用 UTF32Encoding 对象将 Unicode 字符的字符串编码为字节数组。 然后,字节数组将解码为字符串,以证明不会丢失数据。
using System;
using System.Text;
public class Example
{
public static void Main()
{
// The encoding.
var enc = new UTF32Encoding();
// Create a string.
String s = "This string contains two characters " +
"with codes outside the ASCII code range: " +
"Pi (\u03A0) and Sigma (\u03A3).";
Console.WriteLine("Original string:");
Console.WriteLine(" {0}", s);
// Encode the string.
Byte[] encodedBytes = enc.GetBytes(s);
Console.WriteLine();
Console.WriteLine("Encoded bytes:");
for (int ctr = 0; ctr < encodedBytes.Length; ctr++) {
Console.Write("[{0:X2}]{1}", encodedBytes[ctr],
(ctr + 1) % 4 == 0 ? " " : "" );
if ((ctr + 1) % 16 == 0) Console.WriteLine();
}
Console.WriteLine();
// Decode bytes back to string.
// Notice Pi and Sigma characters are still present.
String decodedString = enc.GetString(encodedBytes);
Console.WriteLine();
Console.WriteLine("Decoded string:");
Console.WriteLine(" {0}", decodedString);
}
}
// The example displays the following output:
// Original string:
// This string contains two characters with codes outside the ASCII code range:
// Pi (π) and Sigma (Σ).
//
// Encoded bytes:
// [54][00][00][00] [68][00][00][00] [69][00][00][00] [73][00][00][00]
// [20][00][00][00] [73][00][00][00] [74][00][00][00] [72][00][00][00]
// [69][00][00][00] [6E][00][00][00] [67][00][00][00] [20][00][00][00]
// [63][00][00][00] [6F][00][00][00] [6E][00][00][00] [74][00][00][00]
// [61][00][00][00] [69][00][00][00] [6E][00][00][00] [73][00][00][00]
// [20][00][00][00] [74][00][00][00] [77][00][00][00] [6F][00][00][00]
// [20][00][00][00] [63][00][00][00] [68][00][00][00] [61][00][00][00]
// [72][00][00][00] [61][00][00][00] [63][00][00][00] [74][00][00][00]
// [65][00][00][00] [72][00][00][00] [73][00][00][00] [20][00][00][00]
// [77][00][00][00] [69][00][00][00] [74][00][00][00] [68][00][00][00]
// [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
// [65][00][00][00] [73][00][00][00] [20][00][00][00] [6F][00][00][00]
// [75][00][00][00] [74][00][00][00] [73][00][00][00] [69][00][00][00]
// [64][00][00][00] [65][00][00][00] [20][00][00][00] [74][00][00][00]
// [68][00][00][00] [65][00][00][00] [20][00][00][00] [41][00][00][00]
// [53][00][00][00] [43][00][00][00] [49][00][00][00] [49][00][00][00]
// [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
// [65][00][00][00] [20][00][00][00] [72][00][00][00] [61][00][00][00]
// [6E][00][00][00] [67][00][00][00] [65][00][00][00] [3A][00][00][00]
// [20][00][00][00] [50][00][00][00] [69][00][00][00] [20][00][00][00]
// [28][00][00][00] [A0][03][00][00] [29][00][00][00] [20][00][00][00]
// [61][00][00][00] [6E][00][00][00] [64][00][00][00] [20][00][00][00]
// [53][00][00][00] [69][00][00][00] [67][00][00][00] [6D][00][00][00]
// [61][00][00][00] [20][00][00][00] [28][00][00][00] [A3][03][00][00]
// [29][00][00][00] [2E][00][00][00]
//
// Decoded string:
// This string contains two characters with codes outside the ASCII code range:
// Pi (π) and Sigma (Σ).
Imports System.Text
Class Example
Public Shared Sub Main()
' The encoding.
Dim enc As New UTF32Encoding()
' Create a string.
Dim s As String =
"This string contains two characters " &
"with codes outside the ASCII code range: " &
"Pi (" & ChrW(&h03A0) & ") and Sigma (" & ChrW(&h03A3) & ")."
Console.WriteLine("Original string:")
Console.WriteLine(" {0}", s)
' Encode the string.
Dim encodedBytes As Byte() = enc.GetBytes(s)
Console.WriteLine()
Console.WriteLine("Encoded bytes:")
For ctr As Integer = 0 To encodedBytes.Length - 1
Console.Write("[{0:X2}]{1}", encodedBytes(ctr),
If((ctr + 1) Mod 4 = 0, " ", "" ))
If (ctr + 1) Mod 16 = 0 Then Console.WriteLine()
Next
Console.WriteLine()
' Decode bytes back to string.
' Notice Pi and Sigma characters are still present.
Dim decodedString As String = enc.GetString(encodedBytes)
Console.WriteLine()
Console.WriteLine("Decoded string:")
Console.WriteLine(" {0}", decodedString)
End Sub
End Class
' The example displays the following output:
' Original string:
' This string contains two characters with codes outside the ASCII code range:
' Pi (π) and Sigma (Σ).
'
' Encoded bytes:
' [54][00][00][00] [68][00][00][00] [69][00][00][00] [73][00][00][00]
' [20][00][00][00] [73][00][00][00] [74][00][00][00] [72][00][00][00]
' [69][00][00][00] [6E][00][00][00] [67][00][00][00] [20][00][00][00]
' [63][00][00][00] [6F][00][00][00] [6E][00][00][00] [74][00][00][00]
' [61][00][00][00] [69][00][00][00] [6E][00][00][00] [73][00][00][00]
' [20][00][00][00] [74][00][00][00] [77][00][00][00] [6F][00][00][00]
' [20][00][00][00] [63][00][00][00] [68][00][00][00] [61][00][00][00]
' [72][00][00][00] [61][00][00][00] [63][00][00][00] [74][00][00][00]
' [65][00][00][00] [72][00][00][00] [73][00][00][00] [20][00][00][00]
' [77][00][00][00] [69][00][00][00] [74][00][00][00] [68][00][00][00]
' [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
' [65][00][00][00] [73][00][00][00] [20][00][00][00] [6F][00][00][00]
' [75][00][00][00] [74][00][00][00] [73][00][00][00] [69][00][00][00]
' [64][00][00][00] [65][00][00][00] [20][00][00][00] [74][00][00][00]
' [68][00][00][00] [65][00][00][00] [20][00][00][00] [41][00][00][00]
' [53][00][00][00] [43][00][00][00] [49][00][00][00] [49][00][00][00]
' [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
' [65][00][00][00] [20][00][00][00] [72][00][00][00] [61][00][00][00]
' [6E][00][00][00] [67][00][00][00] [65][00][00][00] [3A][00][00][00]
' [20][00][00][00] [50][00][00][00] [69][00][00][00] [20][00][00][00]
' [28][00][00][00] [A0][03][00][00] [29][00][00][00] [20][00][00][00]
' [61][00][00][00] [6E][00][00][00] [64][00][00][00] [20][00][00][00]
' [53][00][00][00] [69][00][00][00] [67][00][00][00] [6D][00][00][00]
' [61][00][00][00] [20][00][00][00] [28][00][00][00] [A3][03][00][00]
' [29][00][00][00] [2E][00][00][00]
'
' Decoded string:
' This string contains two characters with codes outside the ASCII code range:
' Pi (π) and Sigma (Σ).
以下示例使用与上一个字符串相同的字符串,只不过它将编码的字节写入文件,并使用字节顺序标记(BOM)为字节流添加前缀。 然后,它以两种不同的方式读取文件:使用 StreamReader 对象作为文本文件;作为二进制文件。 正如预期的那样,新读取的字符串都不包括 BOM。
using System;
using System.IO;
using System.Text;
public class Example
{
public static void Main()
{
// Create a UTF-32 encoding that supports a BOM.
var enc = new UTF32Encoding();
// A Unicode string with two characters outside an 8-bit code range.
String s = "This Unicode string has 2 characters " +
"outside the ASCII range: \n" +
"Pi (\u03A0), and Sigma (\u03A3).";
Console.WriteLine("Original string:");
Console.WriteLine(s);
Console.WriteLine();
// Encode the string.
Byte[] encodedBytes = enc.GetBytes(s);
Console.WriteLine("The encoded string has {0} bytes.\n",
encodedBytes.Length);
// Write the bytes to a file with a BOM.
var fs = new FileStream(@".\UTF32Encoding.txt", FileMode.Create);
Byte[] bom = enc.GetPreamble();
fs.Write(bom, 0, bom.Length);
fs.Write(encodedBytes, 0, encodedBytes.Length);
Console.WriteLine("Wrote {0} bytes to the file.\n", fs.Length);
fs.Close();
// Open the file using StreamReader.
var sr = new StreamReader(@".\UTF32Encoding.txt");
String newString = sr.ReadToEnd();
sr.Close();
Console.WriteLine("String read using StreamReader:");
Console.WriteLine(newString);
Console.WriteLine();
// Open the file as a binary file and decode the bytes back to a string.
fs = new FileStream(@".\Utf32Encoding.txt", FileMode.Open);
Byte[] bytes = new Byte[fs.Length];
fs.Read(bytes, 0, (int)fs.Length);
fs.Close();
String decodedString = enc.GetString(bytes);
Console.WriteLine("Decoded bytes from binary file:");
Console.WriteLine(decodedString);
}
}
// The example displays the following output:
// Original string:
// This Unicode string has 2 characters outside the ASCII range:
// Pi (π), and Sigma (Σ).
//
// The encoded string has 340 bytes.
//
// Wrote 344 bytes to the file.
//
// String read using StreamReader:
// This Unicode string has 2 characters outside the ASCII range:
// Pi (π), and Sigma (Σ).
//
// Decoded bytes from binary file:
// This Unicode string has 2 characters outside the ASCII range:
// Pi (π), and Sigma (Σ).
Imports System.IO
Imports System.Text
Class Example
Public Shared Sub Main()
' Create a UTF-32 encoding that supports a BOM.
Dim enc As New UTF32Encoding()
' A Unicode string with two characters outside an 8-bit code range.
Dim s As String = _
"This Unicode string has 2 characters outside the " &
"ASCII range: " & vbCrLf &
"Pi (" & ChrW(&h03A0) & "), and Sigma (" & ChrW(&h03A3) & ")."
Console.WriteLine("Original string:")
Console.WriteLine(s)
Console.WriteLine()
' Encode the string.
Dim encodedBytes As Byte() = enc.GetBytes(s)
Console.WriteLine("The encoded string has {0} bytes.",
encodedBytes.Length)
Console.WriteLine()
' Write the bytes to a file with a BOM.
Dim fs As New FileStream(".\UTF32Encoding.txt", FileMode.Create)
Dim bom() As Byte = enc.GetPreamble()
fs.Write(bom, 0, bom.Length)
fs.Write(encodedBytes, 0, encodedBytes.Length)
Console.WriteLine("Wrote {0} bytes to the file.", fs.Length)
fs.Close()
Console.WriteLine()
' Open the file using StreamReader.
Dim sr As New StreamReader(".\UTF32Encoding.txt")
Dim newString As String = sr.ReadToEnd()
sr.Close()
Console.WriteLine("String read using StreamReader:")
Console.WriteLine(newString)
Console.WriteLine()
' Open the file as a binary file and decode the bytes back to a string.
fs = new FileStream(".\Utf32Encoding.txt", FileMode.Open)
Dim bytes(fs.Length - 1) As Byte
fs.Read(bytes, 0, fs.Length)
fs.Close()
Dim decodedString As String = enc.GetString(bytes)
Console.WriteLine("Decoded bytes from binary file:")
Console.WriteLine(decodedString)
End Sub
End Class
' The example displays the following output:
' Original string:
' This Unicode string has 2 characters outside the ASCII range:
' Pi (π), and Sigma (Σ).
'
' The encoded string has 344 bytes.
'
' Wrote 348 bytes to the file.
'
' String read using StreamReader:
' This Unicode string has 2 characters outside the ASCII range:
' Pi (π), and Sigma (Σ).
'
' Decoded bytes from binary file:
' This Unicode string has 2 characters outside the ASCII range:
' Pi (π), and Sigma (Σ).
注解
编码是将一组 Unicode 字符转换为字节序列的过程。 解码是将编码字节序列转换为一组 Unicode 字符的过程。
Unicode Standard 为每个受支持的脚本中的每个字符分配一个代码点(一个数字)。 Unicode 转换格式(UTF)是编码该代码点的方法。 Unicode 标准版使用以下 UTF:
UTF-8,将每个代码点表示为一到四个字节的序列。
UTF-16,将每个代码点表示为一到两个 16 位整数的序列。
UTF-32,表示每个代码点为 32 位整数。
有关 UTF 和支持的其他编码 System.Text的详细信息,请参阅 .NET 中的字符编码。
该 UTF32Encoding 类表示 UTF-32 编码。 编码器可以使用大字节字节顺序(最重要字节第一)或小字节字节顺序(最不重要的字节优先)。 例如,拉丁文大写字母 A(代码点 U+0041)按如下方式序列化(十六进制):
大尾字节顺序: 00 00 00 41
小尾字节顺序: 41 00 00 00
使用本机字节顺序存储 Unicode 字符通常更高效。 例如,最好在小端平台(如 Intel 计算机)上使用小端字节序。 UTF32Encoding 对应于 Windows 代码页 12000(小字节顺序)和 12001(大字节字节顺序)。 可以通过调用 BitConverter.IsLittleEndian 该方法来确定特定体系结构的“endianness”。
(可选)对象 UTF32Encoding 提供字节顺序标记(BOM),它是一个字节数组,可以前缀为编码过程生成的字节序列。 如果前言包含字节顺序标记(BOM),则它有助于解码器确定字节顺序和字节数组的转换格式或 UTF。
UTF32Encoding如果实例配置为提供 BOM,则可以通过调用GetPreamble该方法来检索它;否则,该方法将返回一个空数组。 请注意,即使为 BOM 支持配置了对象 UTF32Encoding ,也必须在编码字节流的开头包含 BOM;类的 UTF32Encoding 编码方法不会自动执行此操作。
注意
若要启用错误检测并使类实例更安全,应通过调用
可以通过多种方式实例化对象 UTF32Encoding ,具体取决于是要提供字节顺序标记(BOM),是想要使用 big-endian 还是 little-endian 编码,以及是否要启用错误检测。 下表列出了UTF32Encoding返回对象的UnicodeEncoding构造函数和Encoding属性。
| 成员 | 字节排序方式 | BOM | 错误检测 |
|---|---|---|---|
| Encoding.UTF32 | 小端序 (Little-endian) | 是的 | 否(替换回退) |
| UTF32Encoding.UTF32Encoding() | 小端序 (Little-endian) | 是的 | 否(替换回退) |
| UTF32Encoding.UTF32Encoding(Boolean, Boolean) | 可配置 | 可配置 | 否(替换回退) |
| UTF32Encoding.UTF32Encoding(Boolean, Boolean, Boolean) | 可配置 | 可配置 | 可配置 |
该方法 GetByteCount 确定对一组 Unicode 字符进行编码的字节数,该方法 GetBytes 执行实际编码。
同样,该方法 GetCharCount 确定对字节序列进行解码的字符数,以及 GetChars 执行 GetString 实际解码的方法。
对于能够保存状态信息的编码器或解码器,当编码或解码跨越多个块的数据(如编码为 100,000 个字符段的字符串)时,请分别使用 GetEncoder 和 GetDecoder 属性。
构造函数
| 名称 | 说明 |
|---|---|
| UTF32Encoding() |
初始化 UTF32Encoding 类的新实例。 |
| UTF32Encoding(Boolean, Boolean, Boolean) |
初始化 UTF32Encoding 类的新实例。 参数指定是否使用大字节字节顺序、是否提供 Unicode 字节顺序标记,以及是否在检测到无效编码时引发异常。 |
| UTF32Encoding(Boolean, Boolean) |
初始化 UTF32Encoding 类的新实例。 参数指定是否使用大字节字节顺序,以及该方法是否 GetPreamble() 返回 Unicode 字节顺序标记。 |
属性
| 名称 | 说明 |
|---|---|
| BodyName |
在派生类中重写时,获取可用于邮件代理正文标记的当前编码的名称。 (继承自 Encoding) |
| CodePage |
在派生类中重写时,获取当前 Encoding代码页标识符。 (继承自 Encoding) |
| DecoderFallback |
获取或设置 DecoderFallback 当前 Encoding 对象的对象。 (继承自 Encoding) |
| EncoderFallback |
获取或设置 EncoderFallback 当前 Encoding 对象的对象。 (继承自 Encoding) |
| EncodingName |
在派生类中重写时,获取当前编码的人类可读说明。 (继承自 Encoding) |
| HeaderName |
在派生类中重写时,获取可用于邮件代理标头标记的当前编码的名称。 (继承自 Encoding) |
| IsBrowserDisplay |
在派生类中重写时,获取一个值,该值指示浏览器客户端是否可以使用当前编码来显示内容。 (继承自 Encoding) |
| IsBrowserSave |
在派生类中重写时,获取一个值,该值指示浏览器客户端是否可以使用当前编码来保存内容。 (继承自 Encoding) |
| IsMailNewsDisplay |
在派生类中重写时,获取一个值,该值指示邮件和新闻客户端是否可以使用当前编码来显示内容。 (继承自 Encoding) |
| IsMailNewsSave |
在派生类中重写时,获取一个值,该值指示邮件和新闻客户端是否可以使用当前编码来保存内容。 (继承自 Encoding) |
| IsReadOnly |
在派生类中重写时,获取一个值,该值指示当前编码是否为只读。 (继承自 Encoding) |
| IsSingleByte |
在派生类中重写时,获取一个值,该值指示当前编码是否使用单字节码位。 (继承自 Encoding) |
| Preamble |
如果此对象配置为提供一个,则获取以 UTF-32 格式编码的 Unicode 字节顺序标记。 |
| Preamble |
在派生类中重写时,返回包含指定所用编码的字节序列的范围。 (继承自 Encoding) |
| WebName |
在派生类中重写时,获取为当前编码向 Internet 分配号码颁发机构(IANA)注册的名称。 (继承自 Encoding) |
| WindowsCodePage |
在派生类中重写时,获取与当前编码最接近的 Windows 操作系统代码页。 (继承自 Encoding) |
方法
| 名称 | 说明 |
|---|---|
| Clone() |
在派生类中重写时,创建当前 Encoding 对象的浅表副本。 (继承自 Encoding) |
| Equals(Object) |
确定指定的 Object 对象是否等于当前 UTF32Encoding 对象。 |
| GetByteCount(Char[], Int32, Int32) |
计算通过对指定字符数组中的一组字符进行编码而生成的字节数。 |
| GetByteCount(Char[]) |
在派生类中重写时,计算通过编码指定字符数组中的所有字符生成的字节数。 (继承自 Encoding) |
| GetByteCount(Char*, Int32) |
计算从指定字符指针开始对一组字符进行编码生成的字节数。 |
| GetByteCount(ReadOnlySpan<Char>) |
在派生类中重写时,计算通过对指定字符范围中的字符进行编码生成的字节数。 (继承自 Encoding) |
| GetByteCount(String, Int32, Int32) |
在派生类中重写时,计算通过对指定字符串中的一组字符进行编码生成的字节数。 (继承自 Encoding) |
| GetByteCount(String) |
计算通过对指定 String字符进行编码生成的字节数。 |
| GetBytes(Char[], Int32, Int32, Byte[], Int32) |
将指定字符数组中的一组字符编码为指定的字节数组。 |
| GetBytes(Char[], Int32, Int32) |
在派生类中重写时,将指定字符数组中的一组字符编码为字节序列。 (继承自 Encoding) |
| GetBytes(Char[]) |
在派生类中重写时,将指定字符数组中的所有字符编码为字节序列。 (继承自 Encoding) |
| GetBytes(Char*, Int32, Byte*, Int32) |
将一组从指定字符指针开始的字符编码为从指定字节指针开始存储的字节序列。 |
| GetBytes(ReadOnlySpan<Char>, Span<Byte>) |
在派生类中重写时,将字节范围编码为指定只读范围中的一组字符。 (继承自 Encoding) |
| GetBytes(String, Int32, Int32, Byte[], Int32) |
将指定 String 字符集编码为指定的字节数组。 |
| GetBytes(String, Int32, Int32) |
在派生类中重写时,从指定的 |
| GetBytes(String) |
在派生类中重写时,将指定字符串中的所有字符编码为字节序列。 (继承自 Encoding) |
| GetCharCount(Byte[], Int32, Int32) |
计算通过解码指定字节数组中的字节序列生成的字符数。 |
| GetCharCount(Byte[]) |
在派生类中重写时,计算通过解码指定字节数组中的所有字节生成的字符数。 (继承自 Encoding) |
| GetCharCount(Byte*, Int32) |
计算通过解码从指定字节指针开始的字节序列生成的字符数。 |
| GetCharCount(ReadOnlySpan<Byte>) |
在派生类中重写时,计算通过解码提供的只读字节范围生成的字符数。 (继承自 Encoding) |
| GetChars(Byte[], Int32, Int32, Char[], Int32) |
将指定字节数组中的字节序列解码为指定的字符数组。 |
| GetChars(Byte[], Int32, Int32) |
在派生类中重写时,将指定字节数组中的字节序列解码为一组字符。 (继承自 Encoding) |
| GetChars(Byte[]) |
在派生类中重写时,将指定字节数组中的所有字节解码为一组字符。 (继承自 Encoding) |
| GetChars(Byte*, Int32, Char*, Int32) |
将从指定字节指针开始的字节序列解码为从指定字符指针开始存储的一组字符。 |
| GetChars(ReadOnlySpan<Byte>, Span<Char>) |
在派生类中重写时,将指定只读字节范围中的所有字节解码为字符范围。 (继承自 Encoding) |
| GetDecoder() |
获取将 UTF-32 编码的字节序列转换为 Unicode 字符序列的解码器。 |
| GetEncoder() |
获取将 Unicode 字符序列转换为 UTF-32 编码字节序列的编码器。 |
| GetHashCode() |
返回当前实例的哈希代码。 |
| GetMaxByteCount(Int32) |
计算通过编码指定字符数生成的最大字节数。 |
| GetMaxCharCount(Int32) |
计算通过解码指定字节数生成的最大字符数。 |
| GetPreamble() |
如果对象配置为提供一个,则返回以 UTF-32 格式编码的 UTF32Encoding Unicode 字节顺序标记。 |
| GetString(Byte[], Int32, Int32) |
将字节数组中的字节范围解码为字符串。 |
| GetString(Byte[]) |
在派生类中重写时,将指定字节数组中的所有字节解码为字符串。 (继承自 Encoding) |
| GetString(Byte*, Int32) |
在派生类中重写时,将从指定地址开始的指定字节数解码为字符串。 (继承自 Encoding) |
| GetString(ReadOnlySpan<Byte>) |
在派生类中重写时,将指定字节范围中的所有字节解码为字符串。 (继承自 Encoding) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| IsAlwaysNormalized() |
获取一个值,该值指示当前编码是否始终使用默认规范化形式进行规范化。 (继承自 Encoding) |
| IsAlwaysNormalized(NormalizationForm) |
在派生类中重写时,获取一个值,该值指示当前编码是否始终使用指定的规范化形式进行规范化。 (继承自 Encoding) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |
| TryGetBytes(ReadOnlySpan<Char>, Span<Byte>, Int32) |
如果目标足够大,则编码为指定只读范围中的一组字符的字节范围。 (继承自 Encoding) |
| TryGetChars(ReadOnlySpan<Byte>, Span<Char>, Int32) |
如果目标足够大,则从指定的只读范围将字符范围解码为一组字节。 (继承自 Encoding) |
扩展方法
| 名称 | 说明 |
|---|---|
| GetBytes(Encoding, ReadOnlySequence<Char>, IBufferWriter<Byte>) |
使用指定的ReadOnlySequence<T> |
| GetBytes(Encoding, ReadOnlySequence<Char>, Span<Byte>) |
使用指定的ReadOnlySequence<T>值对指定 |
| GetBytes(Encoding, ReadOnlySequence<Char>) |
使用指定的ReadOnlySequence<T>数组将指定的Byte值编码为Encoding数组。 |
| GetBytes(Encoding, ReadOnlySpan<Char>, IBufferWriter<Byte>) |
使用指定的ReadOnlySpan<T>值对指定 |
| GetChars(Encoding, ReadOnlySequence<Byte>, IBufferWriter<Char>) |
使用指定的ReadOnlySequence<T> |
| GetChars(Encoding, ReadOnlySequence<Byte>, Span<Char>) |
使用指定的ReadOnlySequence<T> |
| GetChars(Encoding, ReadOnlySpan<Byte>, IBufferWriter<Char>) |
使用指定的ReadOnlySpan<T> |
| GetString(Encoding, ReadOnlySequence<Byte>) |
使用指定的值将指定的 ReadOnlySequence<T> 值解码为 String 指定的 Encoding。 |