Moved bulk of to_internal in gedcom/encoding.c to here.