Recent Posts
Table of contents
An ASCII String is represented as a stop bit encoded entity. The entity value is interpreted as a sequence of 7-bit ASCII characters.
The stop bit decoding of these fields is executed as follows:
- Determine the byte count of the String value using the stop bit algorithm.
- In the final byte, change the stop bit value from "1" to "0".
- The resultant byte array is the output string value.
An example of this decoding process is shown below.

Picture 3.22 - "String value stop bit decoding"
Decoding code sample for mandatory string fields: public int processStringDecoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) { // Handle empty string if(buffer[offset] == (byte)0x80) { fieldValue.setFieldValue(""); return (offset+1); } // Extract the bytes from the buffer until a stop bit is encountered StringBuffer value = new StringBuffer(); while(!PresenceMap.isBitOnPositionSet(buffer[offset], STOP_BIT_POSTION)) { value.append((char)(buffer[offset++])); } // Extract the last byte and get rid of the stop bit value.append((char)((buffer[offset++] & Byte.MAX_VALUE))); fieldValue.setFieldValue(value); return offset; }
Note:
- Field value represented by byte equals to 0x80 implies the empty String - "" of decoded String value.
Decoding code sample for nullable string fields:public int processStringDecoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) { // Handle null value if(buffer[offset] == (byte)0x80) { fieldValue.setFieldValue(null); return (offset+1); } // Handle empty string value if(buffer[offset] == 0x00 && buffer[offset+1] == (byte)0x80) { fieldValue.setFieldValue(""); return (offset+2); } // Extract the bytes from the buffer until a stop bit is encountered StringBuffer value = new StringBuffer(); while(!PresenceMap.isBitOnPositionSet(buffer[offset], STOP_BIT_POSTION)) { value.append((char)(buffer[offset++])); } // Extract the last byte and get rid of the stop bit value.append((char)((buffer[offset++] & Byte.MAX_VALUE))); fieldValue.setFieldValue(value); return (offset); }
Note:
- Field value represented by 0x80 byte implies the NULL decoded String value (not "" as above).
- Field value represented by 0x00 0x80 bytes implies the empty String - "" of decoded String value.