Decode a range of elements from a byte array and store them in a Unicode character array. : UniCode « Development « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Development » UniCode 
7.29.2.Decode a range of elements from a byte array and store them in a Unicode character array.
Imports System
Imports System.Text

Class MainClass

    Public Shared Sub Main()
        Dim chars() As Char
        Dim bytes() As Byte = {501001050990111010001010}

        Dim uniDecoder As Decoder = Encoding.Unicode.GetDecoder()

        Dim charCount As Integer = uniDecoder.GetCharCount(bytes, 0, bytes.Length)
        chars = New Char(charCount - 1) {}
        Dim charsDecodedCount As Integer = uniDecoder.GetChars(bytes, 0, bytes.Length, chars, 0)

        Console.WriteLine(charsDecodedCount)

        Dim As Char
        For Each c In  chars
            Console.Write("[{0}]", c)
        Next c
    End Sub
End Class
7.29.UniCode
7.29.1.UI with UniCodeUI with UniCode
7.29.2.Decode a range of elements from a byte array and store them in a Unicode character array.
7.29.3.Use the GetByteCount to get the number of bytes required to encode an array of Unicode characters, using UTF8Encoding.
7.29.4.Encode Unicode characters array and store the encoded bytes in a byte array.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.