本文整理汇总了VB.NET中System.Text.Decoder类的典型用法代码示例。如果您正苦于以下问题:VB.NET Decoder类的具体用法?VB.NET Decoder怎么用?VB.NET Decoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Decoder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: dec
' 导入命名空间
Imports System.Text
Public Class dec
Public Shared Sub Main()
' These bytes in UTF-8 correspond to 3 different Unicode
' characters: space (U+0020), # (U+0023), and the biohazard
' symbol (U+2623). Note the biohazard symbol requires 3 bytes
' in UTF-8 (hexadecimal e2, 98, a3). Decoders store state across
' multiple calls to GetChars, handling the case when one char
' is in multiple byte arrays.
Dim bytes1 As Byte() = {&H20, &H23, &HE2}
Dim bytes2 As Byte() = {&H98, &HA3}
Dim chars(3) As Char
Dim d As Decoder = Encoding.UTF8.GetDecoder()
Dim charLen As Integer = d.GetChars(bytes1, 0, bytes1.Length, chars, 0)
' The value of charLen should be 2 now.
charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen)
Dim c As Char
For Each c In chars
Console.Write("U+{0:X4} ", Convert.ToUInt16(c) )
Next c
End Sub
End Class