本文整理汇总了VB.NET中System.Text.UTF7Encoding.GetEncoder方法的典型用法代码示例。如果您正苦于以下问题:VB.NET UTF7Encoding.GetEncoder方法的具体用法?VB.NET UTF7Encoding.GetEncoder怎么用?VB.NET UTF7Encoding.GetEncoder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.UTF7Encoding
的用法示例。
在下文中一共展示了UTF7Encoding.GetEncoder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: UTF7EncodingExample
' 导入命名空间
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class UTF7EncodingExample
Public Shared Sub Main()
'Characters:
' ChrW(97) = a
' ChrW(98) = b
' ChrW(99) = c
' ChrW(768) = `
' ChrW(41120) = valid unicode code point, but not a character
Dim chars() As Char = {ChrW(97), ChrW(98), ChrW(99), ChrW(768), ChrW(41120)}
Dim bytes() As Byte
Dim utf7Encoder As Encoder = Encoding.UTF7.GetEncoder()
Dim byteCount As Integer = utf7Encoder.GetByteCount(chars, 2, 3, True)
bytes = New Byte(byteCount - 1) {}
Dim bytesEncodedCount As Integer = utf7Encoder.GetBytes(chars, 2, 3, bytes, 0, True)
Console.WriteLine("{0} bytes used to encode characters.", bytesEncodedCount)
Console.Write("Encoded bytes: ")
Dim b As Byte
For Each b In bytes
Console.Write("[{0}]", b)
Next b
Console.WriteLine()
End Sub
End Class