本文整理匯總了VB.NET中System.Text.UTF32Encoding.GetDecoder方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET UTF32Encoding.GetDecoder方法的具體用法?VB.NET UTF32Encoding.GetDecoder怎麽用?VB.NET UTF32Encoding.GetDecoder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Text.UTF32Encoding
的用法示例。
在下文中一共展示了UTF32Encoding.GetDecoder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.Text
Public Class SamplesUTF32Encoding
Public Shared Sub Main()
' Get an encoder and a decoder from UTF32Encoding.
Dim u32 As New UTF32Encoding(False, True, True)
Dim myEnc As Encoder = u32.GetEncoder()
Dim myDec As Decoder = u32.GetDecoder()
' The characters to encode:
' Latin Small Letter Z (U+007A)
' Latin Small Letter A (U+0061)
' Combining Breve (U+0306)
' Latin Small Letter AE With Acute (U+01FD)
' Greek Small Letter Beta (U+03B2)
Dim myChars() As Char = {"z"c, "a"c, ChrW(&H0306), ChrW(&H01FD), ChrW(&H03B2)}
Console.Write("The original characters : ")
Console.WriteLine(myChars)
' Encode the character array.
Dim iBC As Integer = myEnc.GetByteCount(myChars, 0, myChars.Length, True)
' NOTE: In Visual Basic, arrays contain one extra element by default.
' The following line creates an array with the exact number of elements required.
Dim myBytes(iBC - 1) As Byte
myEnc.GetBytes(myChars, 0, myChars.Length, myBytes, 0, True)
' Print the resulting bytes.
Console.Write("Using the encoder : ")
Dim i As Integer
For i = 0 To myBytes.Length - 1
Console.Write("{0:X2} ", myBytes(i))
Next i
Console.WriteLine()
' Decode the byte array back into an array of characters.
Dim iCC As Integer = myDec.GetCharCount(myBytes, 0, myBytes.Length, True)
' NOTE: In Visual Basic, arrays contain one extra element by default.
' The following line creates an array with the exact number of elements required.
Dim myDecodedChars(iCC - 1) As Char
myDec.GetChars(myBytes, 0, myBytes.Length, myDecodedChars, 0, True)
' Print the resulting characters.
Console.Write("Using the decoder : ")
Console.WriteLine(myDecodedChars)
End Sub
End Class
'This code produces the following output. The question marks take the place of characters that cannot be displayed at the console.
'
'The original characters : za??ß
'Using the encoder : 7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00
'Using the decoder : za??ß