Any additional feedback? Namespace: System. Text Assembly: mscorlib. GetString Byte[]. Applies to. GetString Byte[], Int32, Int Decodes a range of bytes from a byte array into a string. In this article. Encoding is the process of transforming a set of Unicode characters into a sequence of bytes.
In contrast, decoding is the process of transforming a sequence of encoded bytes into a set of Unicode characters. Note that Encoding is intended to operate on Unicode characters instead of arbitrary binary data, such as byte arrays. If you must encode arbitrary binary data into text, you should use a protocol such as uuencode, which is implemented by methods such as Convert.
NET provides the following implementations of the Encoding class to support current Unicode encodings and other encodings:. Code page This encoding supports all Unicode character values. Also available through the UTF7 property. Also available through the UTF8 property. Both little endian and big endian byte orders are supported. Also available through the Unicode property and the BigEndianUnicode property.
Both little endian code page and big endian code page byte orders are supported. Also available through the UTF32 property. The Encoding class is primarily intended to convert between different encodings and Unicode. Often one of the derived Unicode classes is the correct choice for your app. Use the GetEncoding method to obtain other encodings, and call the GetEncodings method to get a list of all encodings.
The following table lists the encodings supported by. It lists each encoding's code page number and the values of the encoding's EncodingInfo. Name and EncodingInfo. DisplayName properties. A check mark in the. NET Framework support ,. NET Core support , or. NET 5 and later support column indicates that the code page is natively supported by that. NET implementation, regardless of the underlying platform. NET Framework, the availability of other encodings listed in the table depends on the operating system.
NET Core and. NET 5 and later versions, other encodings are available by using the System. CodePagesEncodingProvider class or by deriving from the System. EncodingProvider class. Code pages whose EncodingInfo. Name property corresponds to an international standard do not necessarily comply in full with that standard. 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.
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. The UTF and the UTF encoders can use the big endian byte order most significant byte first or the little endian byte order least significant byte first.
It is generally more efficient to store Unicode characters using the native byte order. For example, it is better to use the little endian byte order on little endian platforms, such as Intel computers. If this byte array is prefixed to an encoded stream, it helps the decoder to identify the encoding format used. For more information on byte order and the byte order mark, see The Unicode Standard at the Unicode home page. You should throw an exception on any data stream error.
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. For ANSI encodings, the best fit behavior is the default. Initializes a new instance of the Encoding class. Initializes a new instance of the Encoding class that corresponds to the specified code page. Initializes a new instance of the Encoding class that corresponds to the specified code page with the specified encoder and decoder fallback strategies.
When overridden in a derived class, gets a name for the current encoding that can be used with mail agent body tags. When overridden in a derived class, gets the code page identifier of the current Encoding.
Gets or sets the DecoderFallback object for the current Encoding object. Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. Unless I'm doing something wrong Encoding. Not really seeing any detail in your question this could be off track. However I suspect that in fact UTF8 will do what you need.
Since Silverlight doesn't have an Encoding. It works for me, hope it's useful to you as well:. See this answer which provide additional information. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 11 years, 2 months ago. Active 6 years, 4 months ago. Viewed 13k times.
0コメント