Name

Encoder

Synopsis

Encoding.GetEncoder() returns an instance of this type, which converts character arrays to byte arrays using the encoding subclass from which it was constructed. This class exposes the GetBytes() method, which converts a sequence of character blocks into a sequence of byte blocks. Since Encoder maintains state between calls to GetBytes(), it can deal with partial sequences that occur at block boundaries.

The last argument to GetBytes() is a boolean that specifies whether the internal buffer is flushed after the method is called. If true, state information on the object is lost between blocks. If false (the default), the buffer is maintained. A call with flushing set to true is needed on the final call to Encoding.GetBytes() to close the byte array properly.

Public MustInherit Class Encoder
                  ' Protected Constructors
   Protected Sub New() 
' Public Instance Methods
   MustInherit Public Function GetByteCount(
        ByVal chars As Char(), ByVal index As Integer, 
        ByVal count As Integer, 
        ByVal flush As Boolean) As Integer  
   MustInherit Public Function GetBytes(ByVal chars As Char(), 
        ByVal charIndex As Integer, 
        ByVal charCount As Integer, ByVal bytes As Byte(), 
        ByVal byteIndex As Integer, 
        ByVal flush As Boolean) As Integer  
End Class

Returned By

Encoding.GetEncoder()

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.