public static String encode(Type source, EncodingCharacters encodingChars) {
StringBuffer field = new StringBuffer();
for (int i = 1; i <= Terser.numComponents(source); i++) {
StringBuffer comp = new StringBuffer();
for (int j = 1; j <= Terser.numSubComponents(source, i); j++) {
Primitive p = Terser.getPrimitive(source, i, j);
comp.append(encodePrimitive(p, encodingChars));
comp.append(encodingChars.getSubcomponentSeparator());
}
field.append(stripExtraDelimiters(comp.toString(), encodingChars.getSubcomponentSeparator()));
field.append(encodingChars.getComponentSeparator());