ONC+ Developer's Guide

Counted Byte Strings

The standard defines a string of n (numbered 0 through n-1) ASCII bytes to be the number n encoded as an unsigned integer, as described previously, and followed by the n bytes of the string. Byte b of the string always precedes byte b+1 of the string, and byte 0 of the string always follows the string's length. The n bytes are followed by enough (0 to 3) residual zero bytes r to make the total byte count a multiple of four.


Counted byte strings are declared as follows.

string object<m>; 


string object<>;  

The constant m denotes an upper bound of the number of bytes that a string can contain. If m is not specified, as in the second declaration, it is assumed to be (2**32) - 1, the maximum length. The constant m would normally be found in a protocol specification. For example, a filing protocol might state that a file name can be no longer than 255 bytes, as follows.

string filename<255>;

String Encoding

Text describes graphic.

Do not encode a length greater than the maximum described in the specification.