Obtains a decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode characters. : UnicodeEncoding « Internationalization I18N « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Internationalization I18N » UnicodeEncodingScreenshots 
Obtains a decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode characters.
 

using System;
using System.Text;

public class SamplesUnicodeEncoding  {

   public static void Main()  {
      UnicodeEncoding u16 = new UnicodeEncodingfalse, true, true );
      Encoder myEnc = u16.GetEncoder();
      Decoder myDec = u16.GetDecoder();

      char[] myChars = new char[] {'\u03B2' };
      int iBC  = myEnc.GetByteCountmyChars, 0, myChars.Length, true );
      byte[] myBytes = new byte[iBC];
      myEnc.GetBytesmyChars, 0, myChars.Length, myBytes, 0true );

      for int i = 0; i < myBytes.Length; i++ )
         Console.Write"{0:X2} ", myBytes[i] );

      int iCC  = myDec.GetCharCountmyBytes, 0, myBytes.Length, true );
      char[] myDecodedChars = new char[iCC];
      myDec.GetCharsmyBytes, 0, myBytes.Length, myDecodedChars, 0true );
      Console.WriteLinemyDecodedChars );
   }
}

   
  
Related examples in the same category
1.Use UnicodeEncoding
2.Get byte count from UnicodeEncoding
3.EncodingInfo Class provides basic information about an encoding.
4.UnicodeEncoding Class represents a UTF-16 encoding of Unicode characters.
5.Create UnicodeEncoding: using the big endian byte order and provide a Unicode byte order mark.
6.Create UnicodeEncoding
7.Unicode version 2.0 character size in bytes.
8.Calculates the number of bytes produced by encoding a set of characters from the specified character array.
9.Calculates the number of bytes produced by encoding the characters in the specified String.
10.Encodes a set of characters from the specified character array into the specified byte array.
11.Encodes a set of characters from the specified String into the specified byte array.
12.Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
13.Decodes a sequence of bytes from the specified byte array into the specified character array.
14.Calculates the maximum number of bytes produced by encoding the specified number of characters.
15.Calculates the maximum number of characters produced by decoding the specified number of bytes.
16.Returns a Unicode byte order mark encoded in UTF-16 format
17.Using Unicode Encoding
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.