Encode Unicode characters array and store the encoded bytes in a byte 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.4.Encode Unicode characters array and store the encoded bytes in a byte array.
Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings

Class MainClass

    Public Shared Sub Main()
        Dim bytes() As Byte

        Dim chars() As Char = {ChrW(35), ChrW(37), ChrW(38), ChrW(928), ChrW(931)}

        Dim uni As New UnicodeEncoding()

        Dim byteCount As Integer = uni.GetByteCount(chars, 12)
        bytes = New Byte(byteCount - 1) {}
        Dim bytesEncodedCount As Integer = uni.GetBytes(chars, 12, bytes, 0)

        Console.WriteLine(bytesEncodedCount)

        Dim As Byte
        For Each b In  bytes
            Console.WriteLine(b)
        Next b
    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.