prtenc |
Table of contents
ProcedurePRTENC ( Encode a character string, portably ) SUBROUTINE PRTENC ( NUMBER, STRING ) AbstractEncode a nonnegative integer number into a character string, portably, using 128 as the base for encoding. Required_ReadingNone. KeywordsCELLS CHARACTER DeclarationsIMPLICIT NONE INTEGER NUMBER CHARACTER*(*) STRING INTEGER MINLEN PARAMETER ( MINLEN = 5 ) Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- NUMBER I Number to be encoded. STRING O Encoded string. MINLEN P Minimum length of string. Detailed_InputNUMBER is an arbitrary nonnegative integer. Detailed_OutputSTRING is the character string implied by the ASCII interpretation of NUMBER when converted to its base 128 representation. Let L be the declared length of STRING, and let NUMBER be given by 0 1 L-1 NUMBER = a 128 + a 128 + ... + a 128 1 2 L Then STRING(i:i) = CHAR(a ) for i = 1, L i Note that, just as for any other "numbers", the "digits" in STRING are arranged from right to left in order of increasing significance. The string is, in effect, "padded with nulls" on the left. ParametersMINLEN is the minimum length of a string into which a number may be encoded. In order to avoid padding long strings with hundreds, possibly thousands of null characters, only the first MINLEN characters of the string are actually used. Note that this also allows the encoded number to be preserved during assignments, STR1 = STR2 so long as both strings are of length MINLEN or greater. Exceptions1) If the length of the output string is less than MINLEN, the error SPICE(INSUFFLEN) is signaled. 2) If the number to be encoded is negative, the error SPICE(OUTOFRANGE) is signaled. MINLEN 3) If the number to be encoded is larger than 128 - 1, the error SPICE(OUTOFRANGE) is signaled. FilesNone. ParticularsThis routine is identical to ENCHAR, except that this routine does not use the machine-dependent encoding base returned by the SPICELIB routine CHBASE. Instead, the base 128 is used. This base is expected to work on all systems supporting ASCII encoding of characters. ExamplesSee: SCARDC, SSIZEC. RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) VersionSPICELIB Version 1.1.0, 12-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. SPICELIB Version 1.0.0, 19-DEC-1995 (NJB) (WLT) |
Fri Dec 31 18:36:40 2021