Encoding Encoding Encoding Encoding Class

定義

表示字元編碼方式。Represents a character encoding.

public ref class Encoding abstract : ICloneable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Encoding : ICloneable
type Encoding = class
    interface ICloneable
Public MustInherit Class Encoding
Implements ICloneable
繼承
EncodingEncodingEncodingEncoding
衍生
屬性
實作

範例

下列範例會將字串轉換到另一個編碼方式。The following example converts a string from one encoding to another.

注意

Byte [] 陣列是唯一的型別,在此範例中,其中包含編碼的資料。The byte[] array is the only type in this example that contains the encoded data. .NET Char 和字串型別是本身是使用 Unicode,因此GetChars呼叫解碼 Unicode 資料。The .NET Char and String types are themselves Unicode, so the GetChars call decodes the data back to Unicode.

using namespace System;
using namespace System::Text;

int main()
{
   String^ unicodeString = "This string contains the unicode character Pi (\u03a0)";
   
   // Create two different encodings.
   Encoding^ ascii = Encoding::ASCII;
   Encoding^ unicode = Encoding::Unicode;
   
   // Convert the string into a byte array.
   array<Byte>^unicodeBytes = unicode->GetBytes( unicodeString );
   
   // Perform the conversion from one encoding to the other.
   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
   
   // Convert the new Byte into[] a char and[] then into a string.
   array<Char>^asciiChars = gcnew array<Char>(ascii->GetCharCount( asciiBytes, 0, asciiBytes->Length ));
   ascii->GetChars( asciiBytes, 0, asciiBytes->Length, asciiChars, 0 );
   String^ asciiString = gcnew String( asciiChars );
   
   // Display the strings created before and after the conversion.
   Console::WriteLine( "Original String*: {0}", unicodeString );
   Console::WriteLine( "Ascii converted String*: {0}", asciiString );
}
// The example displays the following output:
//    Original string: This string contains the unicode character Pi (Π)
//    Ascii converted string: This string contains the unicode character Pi (?)
using System;
using System.Text;

class Example
{
   static void Main()
   {
      string unicodeString = "This string contains the unicode character Pi (\u03a0)";

      // Create two different encodings.
      Encoding ascii = Encoding.ASCII;
      Encoding unicode = Encoding.Unicode;

      // Convert the string into a byte array.
      byte[] unicodeBytes = unicode.GetBytes(unicodeString);

      // Perform the conversion from one encoding to the other.
      byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
         
      // Convert the new byte[] into a char[] and then into a string.
      char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
      ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
      string asciiString = new string(asciiChars);

      // Display the strings created before and after the conversion.
      Console.WriteLine("Original string: {0}", unicodeString);
      Console.WriteLine("Ascii converted string: {0}", asciiString);
   }
}
// The example displays the following output:
//    Original string: This string contains the unicode character Pi (Π)
//    Ascii converted string: This string contains the unicode character Pi (?)
Imports System.Text

Class Example
   Shared Sub Main()
      Dim unicodeString As String = "This string contains the unicode character Pi (" & ChrW(&H03A0) & ")"

      ' Create two different encodings.
      Dim ascii As Encoding = Encoding.ASCII
      Dim unicode As Encoding = Encoding.Unicode

      ' Convert the string into a byte array.
      Dim unicodeBytes As Byte() = unicode.GetBytes(unicodeString)

      ' Perform the conversion from one encoding to the other.
      Dim asciiBytes As Byte() = Encoding.Convert(unicode, ascii, unicodeBytes)

      ' Convert the new byte array into a char array and then into a string.
      Dim asciiChars(ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)-1) As Char
      ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
      Dim asciiString As New String(asciiChars)

      ' Display the strings created before and after the conversion.
      Console.WriteLine("Original string: {0}", unicodeString)
      Console.WriteLine("Ascii converted string: {0}", asciiString)
   End Sub
End Class
' The example displays the following output:
'    Original string: This string contains the unicode character Pi (Π)
'    Ascii converted string: This string contains the unicode character Pi (?)

備註

編碼是將一組 Unicode 字元轉換成位元組序列的處理程序。Encoding is the process of transforming a set of Unicode characters into a sequence of bytes. 相反地,解碼則是將編碼的位元組序列轉換成一組 Unicode 字元的程序。In contrast, decoding is the process of transforming a sequence of encoded bytes into a set of Unicode characters. 如需 Unicode 轉換格式 (UTFs) 和其他支援的編碼資訊Encoding,請參閱 < .NET 中的字元編碼For information about the Unicode Transformation Formats (UTFs) and other encodings supported by Encoding, see Character Encoding in .NET.

請注意,Encoding旨在對 Unicode 字元,而不是任意二進位資料的詳細資訊,例如位元組陣列。Note that Encoding is intended to operate on Unicode characters instead of arbitrary binary data, such as byte arrays. 如果您必須將任意的二進位資料編碼成文字,您應該使用的通訊協定,例如 uuencode,例如實作方法Convert.ToBase64CharArrayIf you must encode arbitrary binary data into text, you should use a protocol such as uuencode, which is implemented by methods such as Convert.ToBase64CharArray.

.NET 提供的下列實作Encoding類別,以支援目前的 Unicode 編碼方式和其他編碼:.NET provides the following implementations of the Encoding class to support current Unicode encodings and other encodings:

  • ASCIIEncoding 將 Unicode 字元編碼為單一 7 位元 ASCII 字元。ASCIIEncoding encodes Unicode characters as single 7-bit ASCII characters. 這個編碼僅支援之間的字元值 U + 0000 和 U + 007F。This encoding only supports character values between U+0000 and U+007F. 已核取 20127 的字碼頁。Code page 20127. 也可透過ASCII屬性。Also available through the ASCII property.

  • UTF7Encoding 使用 utf-7 編碼的 Unicode 字元編碼。UTF7Encoding encodes Unicode characters using the UTF-7 encoding. 這種編碼方式支援所有 Unicode 字元值。This encoding supports all Unicode character values. 65000 的字碼頁。Code page 65000. 也可透過UTF7屬性。Also available through the UTF7 property.

  • UTF8Encoding 使用 utf-8 編碼的 Unicode 字元編碼。UTF8Encoding encodes Unicode characters using the UTF-8 encoding. 這種編碼方式支援所有 Unicode 字元值。This encoding supports all Unicode character values. 字碼頁 65001。Code page 65001. 也可透過UTF8屬性。Also available through the UTF8 property.

  • UnicodeEncoding 使用 utf-16 編碼的 Unicode 字元編碼。UnicodeEncoding encodes Unicode characters using the UTF-16 encoding. 支援這兩個小到小,而且其大小位元組由小到大位元組順序。Both little endian and big endian byte orders are supported. 也可透過Unicode屬性和BigEndianUnicode屬性。Also available through the Unicode property and the BigEndianUnicode property.

  • UTF32Encoding 使用 UTF-32 編碼的 Unicode 字元編碼。UTF32Encoding encodes Unicode characters using the UTF-32 encoding. 同時位元組由小到大 (字碼頁 12000) 和 big endian (字碼頁 12001) 位元組會支援順序。Both little endian (code page 12000) and big endian (code page 12001) byte orders are supported. 也可透過UTF32屬性。Also available through the UTF32 property.

Encoding類別主要是以不同的編碼方式和 Unicode 間轉換。The Encoding class is primarily intended to convert between different encodings and Unicode. 通常的其中一個衍生的 Unicode 類別是您的應用程式的正確選擇。Often one of the derived Unicode classes is the correct choice for your app.

使用GetEncoding方法,以取得其他編碼,並呼叫GetEncodings方法來取得一份所有編碼方式。Use the GetEncoding method to obtain other encodings, and call the GetEncodings method to get a list of all encodings.

下表列出.NET Framework 和.NET Core 所支援的編碼方式。The following table lists the encodings supported by .NET Framework and .NET Core. 它會列出每個編碼的字碼頁編號和編碼方式的值EncodingInfo.NameEncodingInfo.DisplayName屬性。It lists each encoding's code page number and the values of the encoding's EncodingInfo.Name and EncodingInfo.DisplayName properties. 中的核取記號 .NET Framework 支援.NET Core 支援資料行表示.NET 實作,不論基礎平台原生支援的字碼頁。A check mark in the .NET Framework support and .NET Core support columns indicates that the code page is natively supported by that .NET implementation, regardless of the underlying platform. .NET Framework 中,表所列的其他編碼的可用性取決於作業系統。For .NET Framework, the availability of other encodings listed in the table depends on the operating system. 適用於.NET Core,其他編碼,則可使用System.Text.CodePagesEncodingProvider類別,或藉由衍生自System.Text.EncodingProvider類別。For .NET Core, other encodings are available by using the System.Text.CodePagesEncodingProvider class or by deriving from the System.Text.EncodingProvider class.

注意

字碼頁的EncodingInfo.Name屬性會對應至國際標準不一定符合該標準的完整。Code pages whose EncodingInfo.Name property corresponds to an international standard do not necessarily comply in full with that standard.

字碼頁Code page 名稱Name 顯示名稱Display name .NET framework 支援.NET Framework support .NET Core 支援.NET Core support
3737 IBM037IBM037 IBM EBCDIC (美國和加拿大)IBM EBCDIC (US-Canada)
437437 IBM437IBM437 OEM-UsaOEM United States
500500 IBM500IBM500 IBM EBCDIC (國際)IBM EBCDIC (International)
708708 ASMO-708ASMO-708 阿拉伯文 (ASMO 708)Arabic (ASMO 708)
720720 DOS-720DOS-720 阿拉伯文 (DOS)Arabic (DOS)
737737 ibm737ibm737 希臘文 (DOS)Greek (DOS)
775775 ibm775ibm775 波羅的海文 (DOS)Baltic (DOS)
850850 ibm850ibm850 西歐語系 (DOS)Western European (DOS)
852852 ibm852ibm852 中歐語系 (DOS)Central European (DOS)
855855 IBM855IBM855 OEM CyrillicOEM Cyrillic
857857 ibm857ibm857 Turečtina (DOS)Turkish (DOS)
858858 IBM00858IBM00858 OEM 多語系拉丁文 IOEM Multilingual Latin I
860860 IBM860IBM860 Portugalština (DOS)Portuguese (DOS)
861861 ibm861ibm861 Islandština (DOS)Icelandic (DOS)
862862 DOS-862DOS-862 Hebrejština (DOS)Hebrew (DOS)
863863 IBM863IBM863 加拿大法文 (DOS)French Canadian (DOS)
864864 IBM864IBM864 阿拉伯文 (864)Arabic (864)
865865 IBM865IBM865 北歐字母 (DOS)Nordic (DOS)
866866 cp866cp866 Cyrilice (DOS)Cyrillic (DOS)
869869 ibm869ibm869 希臘文,現代 (DOS)Greek, Modern (DOS)
870870 IBM870IBM870 IBM EBCDIC (多語系拉丁文-2)IBM EBCDIC (Multilingual Latin-2)
874874 windows-874windows-874 Thajština (Windows)Thai (Windows)
875875 cp875cp875 IBM EBCDIC (希臘文現代)IBM EBCDIC (Greek Modern)
932932 shift_jisshift_jis 日文 (SHIFT-JIS)Japanese (Shift-JIS)
936936 gb2312gb2312 簡體中文 (GB2312)Chinese Simplified (GB2312)
949949 ks_c_5601-1987ks_c_5601-1987 韓文Korean
950950 big5big5 繁體中文 (Big5)Chinese Traditional (Big5)
10261026 IBM1026IBM1026 IBM EBCDIC (Turečtina-Latin 5)IBM EBCDIC (Turkish Latin-5)
10471047 IBM01047IBM01047 IBM Latin 1IBM Latin-1
11401140 IBM01140IBM01140 IBM EBCDIC (美國-加拿大-歐洲)IBM EBCDIC (US-Canada-Euro)
11411141 IBM01141IBM01141 IBM EBCDIC (Germany-Euro)IBM EBCDIC (Germany-Euro)
11421142 IBM01142IBM01142 IBM EBCDIC (丹麥-挪威-歐洲)IBM EBCDIC (Denmark-Norway-Euro)
11431143 IBM01143IBM01143 IBM EBCDIC (芬蘭-瑞典-歐洲)IBM EBCDIC (Finland-Sweden-Euro)
11441144 IBM01144IBM01144 IBM EBCDIC (Italy-Euro)IBM EBCDIC (Italy-Euro)
11451145 IBM01145IBM01145 IBM EBCDIC (Spain-Euro)IBM EBCDIC (Spain-Euro)
11461146 IBM01146IBM01146 IBM EBCDIC (UK-Euro)IBM EBCDIC (UK-Euro)
11471147 IBM01147IBM01147 IBM EBCDIC (France-Euro)IBM EBCDIC (France-Euro)
11481148 IBM01148IBM01148 IBM EBCDIC (International-Euro)IBM EBCDIC (International-Euro)
11491149 IBM01149IBM01149 IBM EBCDIC (Icelandic-Euro)IBM EBCDIC (Icelandic-Euro)
12001200 utf-16utf-16 UnicodeUnicode
12011201 unicodeFFFEunicodeFFFE Unicode (Big endian)Unicode (Big endian)
12501250 windows-1250windows-1250 中歐語系 (Windows)Central European (Windows)
12511251 windows-1251windows-1251 Cyrilice (Windows)Cyrillic (Windows)
12521252 Windows-1252Windows-1252 西歐語系 (Windows)Western European (Windows)
12531253 windows-1253windows-1253 希臘文 (Windows)Greek (Windows)
12541254 windows-1254windows-1254 土耳其文 (Windows)Turkish (Windows)
12551255 windows-1255windows-1255 希伯來文 (Windows)Hebrew (Windows)
12561256 windows-1256windows-1256 阿拉伯文 (Windows)Arabic (Windows)
12571257 windows-1257windows-1257 波羅的海文 (Windows)Baltic (Windows)
12581258 windows-1258windows-1258 越南文 (Windows)Vietnamese (Windows)
13611361 JohabJohab Korejština (Johab)Korean (Johab)
1000010000 macintoshmacintosh 西歐語系 (Mac)Western European (Mac)
1000110001 x-mac-japanesex-mac-japanese Japonština (Mac)Japanese (Mac)
1000210002 x-mac-chinesetradx-mac-chinesetrad 繁體中文 (Mac)Chinese Traditional (Mac)
1000310003 x-mac-koreanx-mac-korean Korejština (Mac)Korean (Mac)
1000410004 x-mac-arabicx-mac-arabic Arabština (Mac)Arabic (Mac)
1000510005 x-mac-hebrewx-mac-hebrew Hebrejština (Mac)Hebrew (Mac)
1000610006 x-mac-greekx-mac-greek 希臘文 (Mac)Greek (Mac)
1000710007 x-mac-cyrillicx-mac-cyrillic Cyrilice (Mac)Cyrillic (Mac)
1000810008 x-mac-chinesesimpx-mac-chinesesimp 簡體中文 (Mac)Chinese Simplified (Mac)
1001010010 x-mac-romanianx-mac-romanian Rumunština (Mac)Romanian (Mac)
1001710017 烏克蘭文-x-macx-mac-ukrainian Ukrajinština (Mac)Ukrainian (Mac)
1002110021 x-mac-thaix-mac-thai Thajština (Mac)Thai (Mac)
1002910029 x-mac-cex-mac-ce 中歐語系 (Mac)Central European (Mac)
1007910079 x-mac-icelandicx-mac-icelandic Islandština (Mac)Icelandic (Mac)
1008110081 x-mac-turkishx-mac-turkish Turečtina (Mac)Turkish (Mac)
1008210082 x-mac-croatianx-mac-croatian Chorvatština (Mac)Croatian (Mac)
1200012000 utf-32utf-32 Unicode (UTF-32)Unicode (UTF-32)
1200112001 utf-32BEutf-32BE Unicode (UTF-32 Big endian)Unicode (UTF-32 Big endian)
2000020000 x-中文-CNx-Chinese-CNS 繁體中文 (CNS)Chinese Traditional (CNS)
2000120001 x-cp20001x-cp20001 Tchaj-wan TcaTCA Taiwan
2000220002 x-中文-倚天x-Chinese-Eten 繁體中文 (倚天)Chinese Traditional (Eten)
2000320003 x-cp20003x-cp20003 Tchaj-wan Ibm5550IBM5550 Taiwan
2000420004 x-cp20004x-cp20004 Tchaj-wan teleTextTeleText Taiwan
2000520005 x-cp20005x-cp20005 Tchaj-wan WangWang Taiwan
2010520105 x-IA5x-IA5 西歐語系 (IA5)Western European (IA5)
2010620106 x-IA5-Germanx-IA5-German Němčina (IA5)German (IA5)
2010720107 x-IA5-Swedishx-IA5-Swedish 瑞典文 (IA5)Swedish (IA5)
2010820108 x-IA5-Norwegianx-IA5-Norwegian 挪威文 (IA5)Norwegian (IA5)
2012720127 us-asciius-ascii US-ASCIIUS-ASCII
2026120261 x-cp20261x-cp20261 T.61T.61
2026920269 x-cp20269x-cp20269 ISO-6937ISO-6937
2027320273 IBM273IBM273 IBM EBCDIC (Německo)IBM EBCDIC (Germany)
2027720277 IBM277IBM277 IBM EBCDIC (丹麥-挪威)IBM EBCDIC (Denmark-Norway)
2027820278 IBM278IBM278 IBM EBCDIC (芬蘭-瑞典)IBM EBCDIC (Finland-Sweden)
2028020280 IBM280IBM280 IBM EBCDIC (義大利)IBM EBCDIC (Italy)
2028420284 IBM284IBM284 IBM EBCDIC (Spain)IBM EBCDIC (Spain)
2028520285 IBM285IBM285 IBM EBCDIC (英國)IBM EBCDIC (UK)
2029020290 IBM290IBM290 IBM EBCDIC (日文片假名)IBM EBCDIC (Japanese katakana)
2029720297 IBM297IBM297 IBM EBCDIC (Francie)IBM EBCDIC (France)
2042020420 IBM420IBM420 IBM EBCDIC (阿拉伯文)IBM EBCDIC (Arabic)
2042320423 IBM423IBM423 IBM EBCDIC (希臘文)IBM EBCDIC (Greek)
2042420424 IBM424IBM424 IBM EBCDIC (Hebrejština)IBM EBCDIC (Hebrew)
2083320833 x-EBCDIC-KoreanExtendedx-EBCDIC-KoreanExtended IBM EBCDIC (韓文擴充)IBM EBCDIC (Korean Extended)
2083820838 IBM-ThaiIBM-Thai IBM EBCDIC (Thajština)IBM EBCDIC (Thai)
2086620866 koi8-rkoi8-r Cyrilice (KOI8-R)Cyrillic (KOI8-R)
2087120871 IBM871IBM871 IBM EBCDIC (Islandština)IBM EBCDIC (Icelandic)
2088020880 IBM880IBM880 IBM EBCDIC (斯拉夫俄文)IBM EBCDIC (Cyrillic Russian)
2090520905 IBM905IBM905 IBM EBCDIC (Turečtina)IBM EBCDIC (Turkish)
2092420924 IBM00924IBM00924 IBM Latin 1IBM Latin-1
2093220932 EUC-JPEUC-JP Japonština (JIS 0208 1990年和 0212年 1990年)Japanese (JIS 0208-1990 and 0212-1990)
2093620936 x-cp20936x-cp20936 簡體中文 (GB2312-80)Chinese Simplified (GB2312-80)
2094920949 x-cp20949x-cp20949 韓文 WansungKorean Wansung
2102521025 cp1025cp1025 IBM EBCDIC (斯拉夫塞爾維亞文-保加利亞文)IBM EBCDIC (Cyrillic Serbian-Bulgarian)
2186621866 koi8-ukoi8-u Cyrilice (KOI8-U)Cyrillic (KOI8-U)
2859128591 iso-8859-1iso-8859-1 西歐語系 (ISO)Western European (ISO)
2859228592 iso-8859-2iso-8859-2 中歐語系 (ISO)Central European (ISO)
2859328593 iso-8859-3iso-8859-3 拉丁文 3 (ISO)Latin 3 (ISO)
2859428594 iso-8859-4iso-8859-4 波羅的海文 (ISO)Baltic (ISO)
2859528595 iso-8859-5iso-8859-5 Cyrilice (ISO)Cyrillic (ISO)
2859628596 iso-8859-6iso-8859-6 Arabština (ISO)Arabic (ISO)
2859728597 iso-8859-7iso-8859-7 希臘文 (ISO)Greek (ISO)
2859828598 iso-8859-8iso-8859-8 希伯來文 (So-visual)Hebrew (ISO-Visual)
2859928599 iso-8859-9iso-8859-9 Turečtina (ISO)Turkish (ISO)
2860328603 iso-8859-13iso-8859-13 Estonština (ISO)Estonian (ISO)
2860528605 iso-8859-15iso-8859-15 拉丁文 9 (ISO)Latin 9 (ISO)
2900129001 x-Europax-Europa EuropaEuropa
3859838598 iso-8859-8-iiso-8859-8-i Hebrejština (Iso-logical)Hebrew (ISO-Logical)
5022050220 iso-2022-jpiso-2022-jp Japonština (JIS)Japanese (JIS)
5022150221 csISO2022JPcsISO2022JP 日文 (JIS-Povolen 1 bajt Kana)Japanese (JIS-Allow 1 byte Kana)
5022250222 iso-2022-jpiso-2022-jp 日文 (JIS-Povolen 1 bajt Kana-因此 / SI)Japanese (JIS-Allow 1 byte Kana - SO/SI)
5022550225 iso-2022-kriso-2022-kr Korejština (ISO)Korean (ISO)
5022750227 x-cp50227x-cp50227 簡體中文 (ISO-2022)Chinese Simplified (ISO-2022)
5193251932 euc-jpeuc-jp Japonština (EUC)Japanese (EUC)
5193651936 EUC-CNEUC-CN 簡體中文 (EUC)Chinese Simplified (EUC)
5194951949 euc-kreuc-kr Korejština (EUC)Korean (EUC)
5293652936 hz-gb-2312hz-gb-2312 簡體中文 (HZ)Chinese Simplified (HZ)
5493654936 GB18030GB18030 簡體中文 (GB18030)Chinese Simplified (GB18030)
5700257002 x-iscii-dex-iscii-de ISCII 梵文字母ISCII Devanagari
5700357003 x-iscii-bex-iscii-be ISCII 孟加拉文ISCII Bengali
5700457004 x-iscii-tax-iscii-ta Iscii-TamilštinaISCII Tamil
5700557005 x-iscii-tex-iscii-te Iscii-TelugštinaISCII Telugu
5700657006 x-iscii-asx-iscii-as ISCII 阿薩姆文ISCII Assamese
5700757007 x-iscii-orx-iscii-or Iscii-UrijštinaISCII Oriya
5700857008 x-iscii-kax-iscii-ka Iscii-KannadštinaISCII Kannada
5700957009 x-iscii-max-iscii-ma ISCII 馬來亞拉姆文ISCII Malayalam
5701057010 x-iscii-gux-iscii-gu ISCII 古吉拉特文ISCII Gujarati
5701157011 x-iscii-pax-iscii-pa ISCII 旁遮普文ISCII Punjabi
6500065000 utf-7utf-7 Unicode (utf-7)Unicode (UTF-7)
6500165001 utf-8utf-8 Unicode (UTF-8)Unicode (UTF-8)

下列範例會呼叫GetEncoding(Int32)GetEncoding(String)方法,以取得希臘文 (Windows) 程式碼頁面的編碼方式。The following example calls the GetEncoding(Int32) and GetEncoding(String) methods to get the Greek (Windows) code page encoding. 它會比較Encoding顯示相等,並接著對應會顯示的 Unicode 字碼指標及相對應的字碼頁值,每個字元希臘文字母中的方法呼叫所傳回的物件。It compares the Encoding objects returned by the method calls to show that they are equal, and then maps displays the Unicode code point and the corresponding code page value for each character in the Greek alphabet.

using System;
using System.Text;

public class Example
{
   public static void Main()
   {
      Encoding enc = Encoding.GetEncoding(1253);
      Encoding altEnc = Encoding.GetEncoding("windows-1253");
      Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName,
                        altEnc.CodePage, enc.Equals(altEnc));
      string greekAlphabet = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " +
                             "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " +
                             "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " +
                             "Φ φ Χ χ Ψ ψ Ω ω";
      Console.OutputEncoding = Encoding.UTF8;
      byte[] bytes = enc.GetBytes(greekAlphabet);
      Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character",
                        "Unicode Code Point", "Code Page 1253");
      for (int ctr = 0; ctr < bytes.Length; ctr++) {
         if (greekAlphabet[ctr].Equals(' '))
            continue;

         Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet[ctr],
                           GetCodePoint(greekAlphabet[ctr]), bytes[ctr]);
      }
   }

   private static string GetCodePoint(char ch)
   {
      string retVal = "u+";
      byte[] bytes = Encoding.Unicode.GetBytes(ch.ToString());
      for (int ctr = bytes.Length - 1; ctr >= 0; ctr--)
         retVal += bytes[ctr].ToString("X2");

      return retVal;
   }
}
// The example displays the following output:
//       Character      Unicode Code Point       Code Page 1253
//       Α                          u+0391                   C1
//       α                          u+03B1                   E1
//       Β                          u+0392                   C2
//       β                          u+03B2                   E2
//       Γ                          u+0393                   C3
//       γ                          u+03B3                   E3
//       Δ                          u+0394                   C4
//       δ                          u+03B4                   E4
//       Ε                          u+0395                   C5
//       ε                          u+03B5                   E5
//       Ζ                          u+0396                   C6
//       ζ                          u+03B6                   E6
//       Η                          u+0397                   C7
//       η                          u+03B7                   E7
//       Θ                          u+0398                   C8
//       θ                          u+03B8                   E8
//       Ι                          u+0399                   C9
//       ι                          u+03B9                   E9
//       Κ                          u+039A                   CA
//       κ                          u+03BA                   EA
//       Λ                          u+039B                   CB
//       λ                          u+03BB                   EB
//       Μ                          u+039C                   CC
//       μ                          u+03BC                   EC
//       Ν                          u+039D                   CD
//       ν                          u+03BD                   ED
//       Ξ                          u+039E                   CE
//       ξ                          u+03BE                   EE
//       Ο                          u+039F                   CF
//       ο                          u+03BF                   EF
//       Π                          u+03A0                   D0
//       π                          u+03C0                   F0
//       Ρ                          u+03A1                   D1
//       ρ                          u+03C1                   F1
//       Σ                          u+03A3                   D3
//       σ                          u+03C3                   F3
//       ς                          u+03C2                   F2
//       Τ                          u+03A4                   D4
//       τ                          u+03C4                   F4
//       Υ                          u+03A5                   D5
//       υ                          u+03C5                   F5
//       Φ                          u+03A6                   D6
//       φ                          u+03C6                   F6
//       Χ                          u+03A7                   D7
//       χ                          u+03C7                   F7
//       Ψ                          u+03A8                   D8
//       ψ                          u+03C8                   F8
//       Ω                          u+03A9                   D9
//       ω                          u+03C9                   F9
Imports System.Text

Module Example
   Public Sub Main()
      Dim enc As Encoding = Encoding.GetEncoding(1253)
      Dim altEnc As Encoding = Encoding.GetEncoding("windows-1253")
      Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName,
                        altEnc.CodePage, enc.Equals(altEnc))
      Dim greekAlphabet As String = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " +
                                    "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " +
                                    "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " +
                                    "Φ φ Χ χ Ψ ψ Ω ω"
      Console.OutputEncoding = Encoding.UTF8
      Dim bytes() As Byte = enc.GetBytes(greekAlphabet)
      Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character",
                        "Unicode Code Point", "Code Page 1253")
      For ctr As Integer = 0 To bytes.Length - 1
         If greekAlphabet(ctr).Equals(" "c) Then Continue For

         Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet(ctr),
                           GetCodePoint(greekAlphabet(ctr)), bytes(ctr))
      Next

   End Sub
   
   Private Function GetCodePoint(ch As String) As String
      Dim retVal As String = "u+"
      Dim bytes() As Byte = Encoding.Unicode.GetBytes(ch)
      For ctr As Integer = bytes.Length - 1 To 0 Step -1
         retVal += bytes(ctr).ToString("X2")
      Next
      Return retVal
   End Function
End Module
' The example displays the following output:
'    Character      Unicode Code Point       Code Page 1253
'    Α                          u+0391                   C1
'    α                          u+03B1                   E1
'    Β                          u+0392                   C2
'    β                          u+03B2                   E2
'    Γ                          u+0393                   C3
'    γ                          u+03B3                   E3
'    Δ                          u+0394                   C4
'    δ                          u+03B4                   E4
'    Ε                          u+0395                   C5
'    ε                          u+03B5                   E5
'    Ζ                          u+0396                   C6
'    ζ                          u+03B6                   E6
'    Η                          u+0397                   C7
'    η                          u+03B7                   E7
'    Θ                          u+0398                   C8
'    θ                          u+03B8                   E8
'    Ι                          u+0399                   C9
'    ι                          u+03B9                   E9
'    Κ                          u+039A                   CA
'    κ                          u+03BA                   EA
'    Λ                          u+039B                   CB
'    λ                          u+03BB                   EB
'    Μ                          u+039C                   CC
'    μ                          u+03BC                   EC
'    Ν                          u+039D                   CD
'    ν                          u+03BD                   ED
'    Ξ                          u+039E                   CE
'    ξ                          u+03BE                   EE
'    Ο                          u+039F                   CF
'    ο                          u+03BF                   EF
'    Π                          u+03A0                   D0
'    π                          u+03C0                   F0
'    Ρ                          u+03A1                   D1
'    ρ                          u+03C1                   F1
'    Σ                          u+03A3                   D3
'    σ                          u+03C3                   F3
'    ς                          u+03C2                   F2
'    Τ                          u+03A4                   D4
'    τ                          u+03C4                   F4
'    Υ                          u+03A5                   D5
'    υ                          u+03C5                   F5
'    Φ                          u+03A6                   D6
'    φ                          u+03C6                   F6
'    Χ                          u+03A7                   D7
'    χ                          u+03C7                   F7
'    Ψ                          u+03A8                   D8
'    ψ                          u+03C8                   F8
'    Ω                          u+03A9                   D9
'    ω                          u+03C9                   F9

如果要轉換的資料是僅適用於循序區塊 (例如從資料流讀取的資料),或如果資料總量很大,它必須將其分成較小的區塊,您應該使用DecoderEncoder所提供GetDecoder方法或GetEncoder方法,分別的衍生類別。If the data to be converted is available only in sequential blocks (such as data read from a stream) or if the amount of data is so large that it needs to be divided into smaller blocks, you should use the Decoder or the Encoder provided by the GetDecoder method or the GetEncoder method, respectively, of a derived class.

Utf-16 和 UTF-32 編碼器可以使用位元組由大到小位元組順序 (最大顯著性位元組第一次) 或小小的位元組由小到大位元組順序 (最小顯著性位元組第一次)。The UTF-16 and the UTF-32 encoders can use the big endian byte order (most significant byte first) or the little endian byte order (least significant byte first). 例如,(u+0041) 序列化為 Latin Capital Letter 如下 (以十六進位方式):For example, the Latin Capital Letter A (U+0041) is serialized as follows (in hexadecimal):

  • Utf-16 位元組由大到小位元組順序:00 41UTF-16 big endian byte order: 00 41

  • Utf-16 少位元組由小到大位元組順序:41 00UTF-16 little endian byte order: 41 00

  • UTF-32 位元組由大到小位元組順序:00 00 00 41UTF-32 big endian byte order: 00 00 00 41

  • UTF-32 少位元組由小到大位元組順序:41 00 00 00UTF-32 little endian byte order: 41 00 00 00

它會儲存使用原生的位元組順序的 Unicode 字元通常更有效率。It is generally more efficient to store Unicode characters using the native byte order. 比方說,最好使用位元組由小到大的位元組順序少位元組由小到大的平台,例如 Intel 的電腦上。For example, it is better to use the little endian byte order on little endian platforms, such as Intel computers.

GetPreamble方法會擷取的位元組陣列,其中包含位元組順序標記 (BOM)。The GetPreamble method retrieves an array of bytes that includes the byte order mark (BOM). 如果這個位元組陣列,做為編碼的資料流前置詞,它可協助找出所使用的編碼格式的解碼器。If this byte array is prefixed to an encoded stream, it helps the decoder to identify the encoding format used.

如需有關位元組順序和位元組順序標記的詳細資訊,請參閱 Unicode Standard > Unicode 首頁For more information on byte order and the byte order mark, see The Unicode Standard at the Unicode home page.

請注意,編碼的類別可讓錯誤:Note that the encoding classes allow errors to:

  • 以無訊息模式變更為"?"字元。Silently change to a "?" character.

  • 使用"best fit"的字元。Use a "best fit" character.

  • 透過使用特定應用程式的行為變更EncoderFallbackDecoderFallbackU + FFFD Unicode replacement character 類別。Change to an application-specific behavior through use of the EncoderFallback and DecoderFallback classes with the U+FFFD Unicode replacement character.

您應該在發生任何資料流的錯誤會擲回例外狀況。You should throw an exception on any data stream error. 應用程式會使用"throwonerror 」 旗標適用時,或使用EncoderExceptionFallbackDecoderExceptionFallback類別。An app either uses a "throwonerror" flag when applicable or uses the EncoderExceptionFallback and DecoderExceptionFallback classes. 通常不建議使用自動調整的後援,因為它可能會導致資料遺失或造成混淆且低於簡單的字元取代。Best fit fallback is often not recommended because it can cause data loss or confusion and is slower than simple character replacements. ANSI 編碼,則自動調整的行為是預設值。For ANSI encodings, the best fit behavior is the default.

建構函式

Encoding() Encoding() Encoding() Encoding()

初始化 Encoding 類別的新執行個體。Initializes a new instance of the Encoding class.

Encoding(Int32) Encoding(Int32) Encoding(Int32) Encoding(Int32)

初始化對應到指定字碼頁之 Encoding 類別的新執行個體。Initializes a new instance of the Encoding class that corresponds to the specified code page.

Encoding(Int32, EncoderFallback, DecoderFallback) Encoding(Int32, EncoderFallback, DecoderFallback) Encoding(Int32, EncoderFallback, DecoderFallback) Encoding(Int32, EncoderFallback, DecoderFallback)

使用指定的編碼器和解碼器後援策略,初始化對應到指定字碼頁之 Encoding 類別的新執行個體。Initializes a new instance of the Encoding class that corresponds to the specified code page with the specified encoder and decoder fallback strategies.

屬性

ASCII ASCII ASCII ASCII

取得 ASCII (7 位元) 字元集 (Character Set) 的編碼方式。Gets an encoding for the ASCII (7-bit) character set.

BigEndianUnicode BigEndianUnicode BigEndianUnicode BigEndianUnicode

取得 UTF-16 格式的編碼方式,其使用由大到小的位元組順序。Gets an encoding for the UTF-16 format that uses the big endian byte order.

BodyName BodyName BodyName BodyName

在衍生類別中覆寫時,取得可以與郵件代理程式主體標籤一起使用的目前編碼方式名稱。When overridden in a derived class, gets a name for the current encoding that can be used with mail agent body tags.

CodePage CodePage CodePage CodePage

在衍生類別中覆寫時,取得目前 Encoding 的字碼頁識別項。When overridden in a derived class, gets the code page identifier of the current Encoding.

DecoderFallback DecoderFallback DecoderFallback DecoderFallback

取得或設定目前 DecoderFallback 物件的 Encoding 物件。Gets or sets the DecoderFallback object for the current Encoding object.

Default Default Default Default

取得此 .NET 實作的預設編碼。Gets the default encoding for this .NET implementation.

EncoderFallback EncoderFallback EncoderFallback EncoderFallback

取得或設定目前 EncoderFallback 物件的 Encoding 物件。Gets or sets the EncoderFallback object for the current Encoding object.

EncodingName EncodingName EncodingName EncodingName

在衍生類別中覆寫時,取得目前編碼方式的人們可讀取 (Human-Readable) 的描述。When overridden in a derived class, gets the human-readable description of the current encoding.

HeaderName HeaderName HeaderName HeaderName

在衍生類別中覆寫時,取得可以與郵件代理程式標頭標籤一起使用的目前編碼方式名稱。When overridden in a derived class, gets a name for the current encoding that can be used with mail agent header tags.

IsBrowserDisplay IsBrowserDisplay IsBrowserDisplay IsBrowserDisplay

在衍生類別中覆寫時,取得值,指出瀏覽器用戶端是否可以使用目前的編碼方式來顯示內容。When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for displaying content.

IsBrowserSave IsBrowserSave IsBrowserSave IsBrowserSave

在衍生類別中覆寫時,取得值,指出瀏覽器用戶端是否可以使用目前的編碼方式來儲存內容。When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for saving content.

IsMailNewsDisplay IsMailNewsDisplay IsMailNewsDisplay IsMailNewsDisplay

在衍生類別中覆寫時,取得值,指出郵件和新聞用戶端是否可以使用目前的編碼方式來顯示內容。When overridden in a derived class, gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.

IsMailNewsSave IsMailNewsSave IsMailNewsSave IsMailNewsSave

在衍生類別中覆寫時,取得值,指出郵件和新聞用戶端是否可以使用目前的編碼方式來儲存內容。When overridden in a derived class, gets a value indicating whether the current encoding can be used by mail and news clients for saving content.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

在衍生類別中覆寫時,取得值,指出目前的編碼方式是否為唯讀。When overridden in a derived class, gets a value indicating whether the current encoding is read-only.

IsSingleByte IsSingleByte IsSingleByte IsSingleByte

在衍生類別中覆寫時,取得值,指出目前的編碼方式是否使用單一位元組字碼指標。When overridden in a derived class, gets a value indicating whether the current encoding uses single-byte code points.

Preamble Preamble Preamble Preamble
Unicode Unicode Unicode Unicode

以位元組由小到大位元組順序取得 UTF-16 格式的編碼方式。Gets an encoding for the UTF-16 format using the little endian byte order.

UTF32 UTF32 UTF32 UTF32

以位元組由小到大位元組順序取得 UTF-32 格式的編碼方式。Gets an encoding for the UTF-32 format using the little endian byte order.

UTF7 UTF7 UTF7 UTF7

取得 UTF-7 格式的編碼方式。Gets an encoding for the UTF-7 format.

UTF8 UTF8 UTF8 UTF8

取得 UTF-8 格式的編碼方式。Gets an encoding for the UTF-8 format.

WebName WebName WebName WebName

在衍生類別中覆寫時,若要取得目前的編碼方式,請取得向 Internet Assigned Numbers Authority (IANA) 註冊的名稱。When overridden in a derived class, gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.

WindowsCodePage WindowsCodePage WindowsCodePage WindowsCodePage

在衍生類別中覆寫時,請取得最能符合目前編碼方式的 Windows 作業系統字碼頁。When overridden in a derived class, gets the Windows operating system code page that most closely corresponds to the current encoding.

方法

Clone() Clone() Clone() Clone()

在衍生類別中覆寫時,會建立目前 Encoding 物件的淺層複本。When overridden in a derived class, creates a shallow copy of the current Encoding object.

Convert(Encoding, Encoding, Byte[]) Convert(Encoding, Encoding, Byte[]) Convert(Encoding, Encoding, Byte[]) Convert(Encoding, Encoding, Byte[])

將整個位元組陣列從一種編碼方式轉換成另一種編碼方式。Converts an entire byte array from one encoding to another.

Convert(Encoding, Encoding, Byte[], Int32, Int32) Convert(Encoding, Encoding, Byte[], Int32, Int32) Convert(Encoding, Encoding, Byte[], Int32, Int32) Convert(Encoding, Encoding, Byte[], Int32, Int32)

將位元組陣列中的某一位元組範圍由一種編碼方式轉換成另一種編碼方式。Converts a range of bytes in a byte array from one encoding to another.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的 Object 和目前的執行個體是否相等。Determines whether the specified Object is equal to the current instance.

GetByteCount(Char*, Int32) GetByteCount(Char*, Int32) GetByteCount(Char*, Int32) GetByteCount(Char*, Int32)

在衍生類別中覆寫時,計算從指定的字元指標開始,編碼一組字元所產生的位元組數目。When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer.

GetByteCount(Char[]) GetByteCount(Char[]) GetByteCount(Char[]) GetByteCount(Char[])

在衍生類別中覆寫時,計算編碼指定字元陣列中所有字元所產生的位元組數目。When overridden in a derived class, calculates the number of bytes produced by encoding all the characters in the specified character array.

GetByteCount(Char[], Int32, Int32) GetByteCount(Char[], Int32, Int32) GetByteCount(Char[], Int32, Int32) GetByteCount(Char[], Int32, Int32)

在衍生類別中覆寫時,計算從指定的字元陣列編碼一組字元所產生的位元組數目。When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array.

GetByteCount(ReadOnlySpan<Char>) GetByteCount(ReadOnlySpan<Char>) GetByteCount(ReadOnlySpan<Char>) GetByteCount(ReadOnlySpan<Char>)
GetByteCount(String) GetByteCount(String) GetByteCount(String) GetByteCount(String)

在衍生類別中覆寫時,計算編碼指定的字串字元所產生的位元組數目。When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified string.

GetByteCount(String, Int32, Int32) GetByteCount(String, Int32, Int32) GetByteCount(String, Int32, Int32) GetByteCount(String, Int32, Int32)
GetBytes(Char*, Int32, Byte*, Int32) GetBytes(Char*, Int32, Byte*, Int32) GetBytes(Char*, Int32, Byte*, Int32) GetBytes(Char*, Int32, Byte*, Int32)

在衍生類別中覆寫時,從指定字元指標開始將一組字元編碼成位元組序列 (會從指定的位元組指標開始存放這些位元組)。When overridden in a derived class, encodes a set of characters starting at the specified character pointer into a sequence of bytes that are stored starting at the specified byte pointer.

GetBytes(Char[]) GetBytes(Char[]) GetBytes(Char[]) GetBytes(Char[])

在衍生類別中覆寫時,將指定字元陣列中的所有字元編碼成位元組序列。When overridden in a derived class, encodes all the characters in the specified character array into a sequence of bytes.

GetBytes(Char[], Int32, Int32) GetBytes(Char[], Int32, Int32) GetBytes(Char[], Int32, Int32) GetBytes(Char[], Int32, Int32)

在衍生類別中覆寫時,將指定字元陣列中的一組字元編碼成位元組序列。When overridden in a derived class, encodes a set of characters from the specified character array into a sequence of bytes.

GetBytes(Char[], Int32, Int32, Byte[], Int32) GetBytes(Char[], Int32, Int32, Byte[], Int32) GetBytes(Char[], Int32, Int32, Byte[], Int32) GetBytes(Char[], Int32, Int32, Byte[], Int32)

在衍生類別中覆寫時,將指定字元陣列中的一組字元編碼成指定的位元組陣列。When overridden in a derived class, encodes a set of characters from the specified character array into the specified byte array.

GetBytes(ReadOnlySpan<Char>, Span<Byte>) GetBytes(ReadOnlySpan<Char>, Span<Byte>) GetBytes(ReadOnlySpan<Char>, Span<Byte>) GetBytes(ReadOnlySpan<Char>, Span<Byte>)
GetBytes(String) GetBytes(String) GetBytes(String) GetBytes(String)

在衍生類別中覆寫時,將指定字串中的所有字元編碼成位元組序列。When overridden in a derived class, encodes all the characters in the specified string into a sequence of bytes.

GetBytes(String, Int32, Int32) GetBytes(String, Int32, Int32) GetBytes(String, Int32, Int32) GetBytes(String, Int32, Int32)
GetBytes(String, Int32, Int32, Byte[], Int32) GetBytes(String, Int32, Int32, Byte[], Int32) GetBytes(String, Int32, Int32, Byte[], Int32) GetBytes(String, Int32, Int32, Byte[], Int32)

在衍生類別中覆寫時,將指定字串中的一組字元編碼成指定的位元組陣列。When overridden in a derived class, encodes a set of characters from the specified string into the specified byte array.

GetCharCount(Byte*, Int32) GetCharCount(Byte*, Int32) GetCharCount(Byte*, Int32) GetCharCount(Byte*, Int32)

在衍生類別中覆寫時,計算從指定的位元組指標開始,解碼位元組序列所產生的字元數目。When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.

GetCharCount(Byte[]) GetCharCount(Byte[]) GetCharCount(Byte[]) GetCharCount(Byte[])

在衍生類別中覆寫時,計算解碼指定位元組陣列中所有位元組所產生的字元數目。When overridden in a derived class, calculates the number of characters produced by decoding all the bytes in the specified byte array.

GetCharCount(Byte[], Int32, Int32) GetCharCount(Byte[], Int32, Int32) GetCharCount(Byte[], Int32, Int32) GetCharCount(Byte[], Int32, Int32)

在衍生類別中覆寫時,計算從指定的位元組陣列解碼位元組序列所產生的字元數目。When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.

GetCharCount(ReadOnlySpan<Byte>) GetCharCount(ReadOnlySpan<Byte>) GetCharCount(ReadOnlySpan<Byte>) GetCharCount(ReadOnlySpan<Byte>)
GetChars(Byte*, Int32, Char*, Int32) GetChars(Byte*, Int32, Char*, Int32) GetChars(Byte*, Int32, Char*, Int32) GetChars(Byte*, Int32, Char*, Int32)

在衍生類別中覆寫時,從指定位元組指標開始將位元組序列解碼成一組字元 (會從指定的字元指標開始存放這些字元)。When overridden in a derived class, decodes a sequence of bytes starting at the specified byte pointer into a set of characters that are stored starting at the specified character pointer.

GetChars(Byte[]) GetChars(Byte[]) GetChars(Byte[]) GetChars(Byte[])

在衍生類別中覆寫時,將指定位元組陣列中的所有位元組解碼成一組字元。When overridden in a derived class, decodes all the bytes in the specified byte array into a set of characters.

GetChars(Byte[], Int32, Int32) GetChars(Byte[], Int32, Int32) GetChars(Byte[], Int32, Int32) GetChars(Byte[], Int32, Int32)

在衍生類別中覆寫時,將指定位元組陣列中的位元組序列解碼成一組字元。When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a set of characters.

GetChars(Byte[], Int32, Int32, Char[], Int32) GetChars(Byte[], Int32, Int32, Char[], Int32) GetChars(Byte[], Int32, Int32, Char[], Int32) GetChars(Byte[], Int32, Int32, Char[], Int32)

在衍生類別中覆寫時,將指定位元組陣列中的位元組序列解碼成指定的字元陣列。When overridden in a derived class, decodes a sequence of bytes from the specified byte array into the specified character array.

GetChars(ReadOnlySpan<Byte>, Span<Char>) GetChars(ReadOnlySpan<Byte>, Span<Char>) GetChars(ReadOnlySpan<Byte>, Span<Char>) GetChars(ReadOnlySpan<Byte>, Span<Char>)
GetDecoder() GetDecoder() GetDecoder() GetDecoder()

在衍生類別中覆寫時,取得會將編碼的位元組序列轉換成字元序列的解碼器。When overridden in a derived class, obtains a decoder that converts an encoded sequence of bytes into a sequence of characters.

GetEncoder() GetEncoder() GetEncoder() GetEncoder()

在衍生類別中覆寫時,取得會將 Unicode 字元序列轉換成編碼的位元組序列的編碼器。When overridden in a derived class, obtains an encoder that converts a sequence of Unicode characters into an encoded sequence of bytes.

GetEncoding(Int32) GetEncoding(Int32) GetEncoding(Int32) GetEncoding(Int32)

傳回與指定字碼頁識別項相關聯的編碼方式。Returns the encoding associated with the specified code page identifier.

GetEncoding(Int32, EncoderFallback, DecoderFallback) GetEncoding(Int32, EncoderFallback, DecoderFallback) GetEncoding(Int32, EncoderFallback, DecoderFallback) GetEncoding(Int32, EncoderFallback, DecoderFallback)

傳回與指定字碼頁識別項相關聯的編碼方式。Returns the encoding associated with the specified code page identifier. 參數會針對無法編碼的字元以及無法解碼的位元組序列指定錯誤處理常式。Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded.

GetEncoding(String) GetEncoding(String) GetEncoding(String) GetEncoding(String)

傳回與指定字碼頁名稱相關聯的編碼方式。Returns the encoding associated with the specified code page name.

GetEncoding(String, EncoderFallback, DecoderFallback) GetEncoding(String, EncoderFallback, DecoderFallback) GetEncoding(String, EncoderFallback, DecoderFallback) GetEncoding(String, EncoderFallback, DecoderFallback)

傳回與指定字碼頁名稱相關聯的編碼方式。Returns the encoding associated with the specified code page name. 參數會針對無法編碼的字元以及無法解碼的位元組序列指定錯誤處理常式。Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded.

GetEncodings() GetEncodings() GetEncodings() GetEncodings()

傳回包含所有編碼方式的陣列。Returns an array that contains all encodings.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回目前執行個體的雜湊碼。Returns the hash code for the current instance.

GetMaxByteCount(Int32) GetMaxByteCount(Int32) GetMaxByteCount(Int32) GetMaxByteCount(Int32)

在衍生類別中覆寫時,計算編碼指定的字元數所產生的最大位元組數目。When overridden in a derived class, calculates the maximum number of bytes produced by encoding the specified number of characters.

GetMaxCharCount(Int32) GetMaxCharCount(Int32) GetMaxCharCount(Int32) GetMaxCharCount(Int32)

在衍生類別中覆寫時,計算解碼指定的位元組數目所產生的最大字元數目。When overridden in a derived class, calculates the maximum number of characters produced by decoding the specified number of bytes.

GetPreamble() GetPreamble() GetPreamble() GetPreamble()

在衍生類別中覆寫時,傳回可指定所用編碼方式的位元組序列。When overridden in a derived class, returns a sequence of bytes that specifies the encoding used.

GetString(Byte*, Int32) GetString(Byte*, Int32) GetString(Byte*, Int32) GetString(Byte*, Int32)

在衍生類別中覆寫時,將指定位址開頭之指定數目的位元組解碼為字串。When overridden in a derived class, decodes a specified number of bytes starting at a specified address into a string.

GetString(Byte[]) GetString(Byte[]) GetString(Byte[]) GetString(Byte[])

在衍生類別中覆寫時,將指定位元組陣列中的所有位元組解碼成字串。When overridden in a derived class, decodes all the bytes in the specified byte array into a string.

GetString(Byte[], Int32, Int32) GetString(Byte[], Int32, Int32) GetString(Byte[], Int32, Int32) GetString(Byte[], Int32, Int32)

在衍生類別中覆寫時,將指定位元組陣列中的位元組序列解碼成字串。When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a string.

GetString(ReadOnlySpan<Byte>) GetString(ReadOnlySpan<Byte>) GetString(ReadOnlySpan<Byte>) GetString(ReadOnlySpan<Byte>)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IsAlwaysNormalized() IsAlwaysNormalized() IsAlwaysNormalized() IsAlwaysNormalized()

取得值,指出目前的編碼方式是否永遠都是使用預設的正規化表單進行正規化。Gets a value indicating whether the current encoding is always normalized, using the default normalization form.

IsAlwaysNormalized(NormalizationForm) IsAlwaysNormalized(NormalizationForm) IsAlwaysNormalized(NormalizationForm) IsAlwaysNormalized(NormalizationForm)

在衍生類別中覆寫時取得值,指出目前的編碼方式是否永遠都是使用指定的正規化表單進行正規化。When overridden in a derived class, gets a value indicating whether the current encoding is always normalized, using the specified normalization form.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from Object)
RegisterProvider(EncodingProvider) RegisterProvider(EncodingProvider) RegisterProvider(EncodingProvider) RegisterProvider(EncodingProvider)

註冊編碼提供者。Registers an encoding provider.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱