private void encodePointer(Encoder encoder, Pointer type, AddressSpace spc, TypeDef typeDef,
			int size) throws IOException {
		encoder.openElement(ELEM_TYPE);
		if (typeDef == null) {
			encoder.writeString(ATTRIB_NAME, "");
		}
		else {
			encodeNameIdAttributes(encoder, typeDef);	// Use the typedef name and id
		}
		encoder.writeString(ATTRIB_METATYPE, "ptr");
		int ptrLen = type.getLength();
		if (ptrLen <= 0) {
			ptrLen = size;
		}
		encoder.writeSignedInteger(ATTRIB_SIZE, ptrLen);
		if (pointerWordSize != 1) {
			encoder.writeUnsignedInteger(ATTRIB_WORDSIZE, pointerWordSize);
		}
		if (spc != null) {
			encoder.writeSpace(ATTRIB_SPACE, spc);
		}
		DataType ptrto = type.getDataType();

		if (ptrto != null && ptrto.getDataTypeManager() != progDataTypes) {
			ptrto = ptrto.clone(progDataTypes);
		}

		if (ptrto == null) {
			encodeTypeRef(encoder, DefaultDataType.dataType, 1);
		}
		else if (ptrto instanceof AbstractStringDataType) {
			if ((ptrto instanceof StringDataType) || (type instanceof TerminatedStringDataType)) {	// Convert pointer to string
				encodeCharTypeRef(encoder, dataOrganization.getCharSize()); // to pointer to char
			}
			else if (ptrto instanceof StringUTF8DataType) {	// Convert pointer to string
				// TODO: Need to ensure that UTF8 decoding applies
				encodeCharTypeRef(encoder, 1); // to pointer to char
			}
			else if ((ptrto instanceof UnicodeDataType) ||
				(ptrto instanceof TerminatedUnicodeDataType)) {
				encodeCharTypeRef(encoder, 2);
			}
			else if ((ptrto instanceof Unicode32DataType) ||
				(ptrto instanceof TerminatedUnicode32DataType)) {
				encodeCharTypeRef(encoder, 4);
			}
			else {
				encodeOpaqueString(encoder, ptrto, 16384);
			}
		}
		else if (ptrto instanceof FunctionDefinition) {
			// FunctionDefinition may have size of -1, do not translate to undefined
			encodeTypeRef(encoder, ptrto, ptrto.getLength());
		}
		else if (ptrto.getLength() < 0 && !(ptrto instanceof FunctionDefinition)) {
			encodeTypeRef(encoder, Undefined1DataType.dataType, 1);
		}
		else {
			encodeTypeRef(encoder, ptrto, ptrto.getLength());
		}
		encoder.closeElement(ELEM_TYPE);
	}
Encode a Pointer data-type to the stream.
@param encoder is the stream encoder
@param type is the Pointer data-type
@param spc if non-null, is the specific address space associated with the pointer
@param typeDef if non-null is the base TypeDef for this special form pointer
@param size if non-zero, is the size of the data-type in context
@throws IOException for errors in the underlying stream
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/PcodeDataTypeManager.java