Table of contents

 

Byte Vector and Unicode String fields are represented as an Unsigned Integer size preamble followed by the specified number of raw bytes.
Each byte in the data part has eight significant data bits. As a consequence, the data part is not stop bit encoded.
A nullable field has a nullable size preamble. A NULL size preample represents a NULL value of this field. s

The following diagram illustrates a unicode-8 string decoding example.

Byte Vector and Unicode String fields stop bit decoding

Picture 3.23 - "Byte Vector and Unicode String fields stop bit decoding"

The following sample code shows the decoding process for byte vectors and unicode string for non-nullable fields:

    public int processByteVectorDecoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) {
        int valueByteCount = 0;
        while (!PresenceMap.hasBitOnPosition(buffer[offset], STOP_BIT_POSTION)) {
            valueByteCount = (valueByteCount << 7) | (buffer[offset++]);
        }
        valueByteCount = (valueByteCount << 7) | (buffer[offset++] & Byte.MAX_VALUE);
        String strValue = null;
        if (valueByteCount == 0) {
            strValue = "";
        }
        if (valueByteCount > 0) {
            strValue = new String(buffer, offset, valueByteCount);
        }
        fieldValue.setFieldValue(strValue);
        return offset;
    }
The next code sample shows the decoding process for the same type (byte vectors and unicode string) but for nullable fields:
    public int processByteVectorDecoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) {
        int valueByteCount = 0;
        while (!PresenceMap.hasBitOnPosition(buffer[offset], STOP_BIT_POSTION)) {
            valueByteCount = (valueByteCount << 7) | (buffer[offset++]);
        }
        valueByteCount = (valueByteCount << 7) | (buffer[offset++] & Byte.MAX_VALUE);
        String strValue = null;
        valueByteCount--;
        if (valueByteCount == 0) {
            strValue = "";
        }
        if (valueByteCount > 0) {
            strValue = new String(buffer, offset, valueByteCount);
        }
        fieldValue.setFieldValue(strValue);
        return offset;
    }