Click or drag to resize

BinaryTextEncodingStxEtx Property

An encoder that will encode and decode STX/ETX delimted ASCII strings.

Namespace:  Demo3D.IO
Assembly:  Demo3D.IO (in Demo3D.IO.dll) Version: 15.0.2.11458
Syntax
C#
public static BinaryTextEncoding StxEtx { get; }

Property Value

Type: BinaryTextEncoding
Examples

The following example shows simple examples for reading and writing strings.

C#
public string StringDelimitedStrings(IDataReader receivedPacket) {
    // The string to be read will start with '<<' and end with '>>'.  The string returned will have the
    // quotes ('<<' and '>>') stripped off.  Just the original string between the quotes will be returned.
    return receivedPacket.ReadString(BinaryTextEncoding.StringDelimited("<<", ">>"));
}

public string PipeDelimitedStrings(IDataReader receivedPacket) {
    // The string is terminated with a '|' character.  Effectively the protocol uses strings separated with '|'.
    return receivedPacket.ReadString(BinaryTextEncoding.StringDelimited(null, "|"));
}

public void StxEtxDelimitedStrings(IDataReader receivedPacket, IDataWriter packetToSend) {
    // The standard STX ETX encapsulated format.
    var str = receivedPacket.ReadString(BinaryTextEncoding.StxEtx);

    // Writes the string "hello" prepended with the STX character and appended with the ETX character.
    packetToSend.WriteString("hello", BinaryTextEncoding.StxEtx);
}
See Also