UI with UniCode : UniCode « Development « VB.Net Tutorial






UI with UniCode
Imports System.Windows.Forms

public class UnicodeUI
   public Shared Sub Main
        Application.Run(New FrmUnicode)
   End Sub
End class


Public Class FrmUnicode
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lblEnglish As System.Windows.Forms.Label
    Friend WithEvents lblChinese As System.Windows.Forms.Label
    Friend WithEvents lblFrench As System.Windows.Forms.Label
    Friend WithEvents lblPortuguese As System.Windows.Forms.Label
    Friend WithEvents lblGerman As System.Windows.Forms.Label
    Friend WithEvents lblRussian As System.Windows.Forms.Label
    Friend WithEvents lblJapanese As System.Windows.Forms.Label
    Friend WithEvents lblSpanish As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lblEnglish = New System.Windows.Forms.Label()
        Me.lblChinese = New System.Windows.Forms.Label()
        Me.lblFrench = New System.Windows.Forms.Label()
        Me.lblPortuguese = New System.Windows.Forms.Label()
        Me.lblGerman = New System.Windows.Forms.Label()
        Me.lblRussian = New System.Windows.Forms.Label()
        Me.lblJapanese = New System.Windows.Forms.Label()
        Me.lblSpanish = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'lblEnglish
        '
        Me.lblEnglish.Location = New System.Drawing.Point(16, 24)
        Me.lblEnglish.Name = "lblEnglish"
        Me.lblEnglish.Size = New System.Drawing.Size(168, 40)
        Me.lblEnglish.TabIndex = 0
        Me.lblEnglish.Text = "Label1"
        '
        'lblChinese
        '
        Me.lblChinese.Location = New System.Drawing.Point(304, 200)
        Me.lblChinese.Name = "lblChinese"
        Me.lblChinese.Size = New System.Drawing.Size(168, 40)
        Me.lblChinese.TabIndex = 1
        Me.lblChinese.Text = "Label2"
        '
        'lblFrench
        '
        Me.lblFrench.Location = New System.Drawing.Point(16, 80)
        Me.lblFrench.Name = "lblFrench"
        Me.lblFrench.Size = New System.Drawing.Size(168, 40)
        Me.lblFrench.TabIndex = 2
        Me.lblFrench.Text = "Label3"
        '
        'lblPortuguese
        '
        Me.lblPortuguese.Location = New System.Drawing.Point(304, 24)
        Me.lblPortuguese.Name = "lblPortuguese"
        Me.lblPortuguese.Size = New System.Drawing.Size(168, 40)
        Me.lblPortuguese.TabIndex = 3
        Me.lblPortuguese.Text = "Label4"
        '
        'lblGerman
        '
        Me.lblGerman.Location = New System.Drawing.Point(16, 136)
        Me.lblGerman.Name = "lblGerman"
        Me.lblGerman.Size = New System.Drawing.Size(168, 40)
        Me.lblGerman.TabIndex = 4
        Me.lblGerman.Text = "Label5"
        '
        'lblRussian
        '
        Me.lblRussian.Location = New System.Drawing.Point(304, 80)
        Me.lblRussian.Name = "lblRussian"
        Me.lblRussian.Size = New System.Drawing.Size(168, 40)
        Me.lblRussian.TabIndex = 5
        Me.lblRussian.Text = "Label6"
        '
        'lblJapanese
        '
        Me.lblJapanese.Location = New System.Drawing.Point(16, 200)
        Me.lblJapanese.Name = "lblJapanese"
        Me.lblJapanese.Size = New System.Drawing.Size(168, 40)
        Me.lblJapanese.TabIndex = 6
        Me.lblJapanese.Text = "Label7"
        '
        'lblSpanish
        '
        Me.lblSpanish.Location = New System.Drawing.Point(304, 136)
        Me.lblSpanish.Name = "lblSpanish"
        Me.lblSpanish.Size = New System.Drawing.Size(168, 40)
        Me.lblSpanish.TabIndex = 7
        Me.lblSpanish.Text = "Label8"
        '
        'FrmUnicode
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(576, 277)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblSpanish, Me.lblJapanese, Me.lblRussian, Me.lblGerman, Me.lblPortuguese, Me.lblFrench, Me.lblChinese, Me.lblEnglish})
        Me.Name = "FrmUnicode"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

        'English
        lblEnglish.Text = ChrW(&H57) & ChrW(&H65) & ChrW(&H6C) & _
            ChrW(&H63) & ChrW(&H6F) & ChrW(&H6D) & ChrW(&H65) & _
            ChrW(&H20) & ChrW(&H74) & ChrW(&H6F) & ChrW(&H20) & _
            "Unicode" & ChrW(&H21)

        'French
        lblFrench.Text = ChrW(&H42) & ChrW(&H69) & ChrW(&H65) & _
            ChrW(&H6E) & ChrW(&H76) & ChrW(&H65) & ChrW(&H6E) & _
            ChrW(&H75) & ChrW(&H65) & ChrW(&H20) & ChrW(&H61) & _
            ChrW(&H75) & ChrW(&H20) & "Unicode" & ChrW(&H21)

        'German
        lblGerman.Text = ChrW(&H57) & ChrW(&H69) & ChrW(&H6C) & _
                ChrW(&H6B) & ChrW(&H6F) & ChrW(&H6D) & ChrW(&H6D) & _
                ChrW(&H75) & ChrW(&H6E) & ChrW(&H20) & ChrW(&H7A) & _
                ChrW(&H75) & ChrW(&H20) & "Unicode" & ChrW(&H21)

        'Japanese
        lblJapanese.Text = "Unicode" & ChrW(&H3078) & _
            ChrW(&H3087) & ChrW(&H3045) & ChrW(&H3053) & _
            ChrW(&H305D) & ChrW(&H21)

        'Portuguese
        lblPortuguese.Text = ChrW(&H53) & ChrW(&HE9) & ChrW(&H6A) & _
            ChrW(&H61) & ChrW(&H20) & ChrW(&H42) & _
            ChrW(&H65) & ChrW(&H6D) & ChrW(&H76) & _
            ChrW(&H69) & ChrW(&H6E) & ChrW(&H64) & _
            ChrW(&H6F) & ChrW(&H20) & "Unicode" & ChrW(&H21)

        'Russian
        lblRussian.Text = ChrW(&H414) & ChrW(&H43E) & ChrW(&H431) & _
                    ChrW(&H440) & ChrW(&H43E) & ChrW(&H20) & _
                    ChrW(&H43F) & ChrW(&H43E) & ChrW(&H436) & _
                    ChrW(&H430) & ChrW(&H43B) & ChrW(&H43E) & _
                    ChrW(&H432) & ChrW(&H430) & ChrW(&H442) & _
                    ChrW(&H44A) & ChrW(&H20) & ChrW(&H432) & _
                    ChrW(&H20) & "Unicode" & ChrW(&H21)

        'Spanish
        lblSpanish.Text = ChrW(&H42) & ChrW(&H69) & ChrW(&H65) & _
                    ChrW(&H6E) & ChrW(&H76) & ChrW(&H65) & _
                    ChrW(&H6E) & ChrW(&H69) & ChrW(&H64) & _
                    ChrW(&H61) & ChrW(&H20) & ChrW(&H61) & _
                    ChrW(&H20) & "Unicode" & ChrW(&H21)

        'Traditional Chinese
        lblChinese.Text = ChrW(&H6B22) & ChrW(&H8FCE) & _
            ChrW(&H4F7F) & ChrW(&H7528) & ChrW(&H20) & _
            "Unicode" & ChrW(&H21)



    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.