Hunny Software Library Reference

ByteString Class

Class that represents an immutable sequence of bytes

For a list of all members of this type, see ByteString Members.

System.Object
   ByteString

[Visual Basic]
NotInheritable Public Class ByteString
Implements IComparable, ICloneable
[C#]
public sealed class ByteString : IComparable, ICloneable

Remarks

This class is similar to System.String. It is different because it contains bytes instead of chars. ByteString is needed in MIME.NET because MIME messages or documents are always sequences of bytes.

The methods and properties provided by ByteString are similar to the methods and properties of System.String, so that a developer familiar with System.String should be able to work efficiently with ByteString.

Like System.String, ByteString is an immutable class. The ByteStringBuilder class can be used like System.Text.StringBuilder to create a new ByteString instance.

You may use ByteString to work with text, especially ASCII text or 8-bit character sets such as ISO-8859-?. However, because ByteString deals with bytes, it may contain data that is not text, such as binary data from an image file. You may also use ByteString to work with text that is encoded with a character encoding other than UTF-16, such as UTF-8 or Shift_JIS.

Keep in mind the dual nature of ByteString: it may contain text or binary data. In most situations, you know from the context whether a particular instance contains text or binary data. Messages that are sent or received via email contain text (which may be the ASCII characters of base64-encoded content). Decoded data or data read from a file may contain binary data. Typically, you obtain the content type from a Content-Type header field or a filename extension.

The text processing methods of ByteString allow you to process 8-bit text efficiently, without having to convert to Unicode characters. The disadvantage, though, is that you must be aware of the particular 8-bit character set that a byte string uses.

Requirements

Namespace: Hunny.Base

Assembly: Hunny.Base (in Hunny.Base.dll)

See Also

ByteString Members | Hunny.Base Namespace