ENCODCOMPAT Function

Verifies the transcoding compatibility between two encodings.
Category: Encoding

Syntax

ENCODCOMPAT(source1,<source2>)

Required Arguments

source1
a character string that represents an encoding.
source2
a character string that represents an encoding. This argument is optional.

Details

If you specify one encoding, the function verifies the compatibility of the specified encoding with the current SAS session encoding.
If you specify two encodings, the function verifies the compatibility of the two encodings.
The function compares two encoding identifiers and determines whether the data needs to be transcoded. Source1 is the source encoding. Source2 is the destination encoding. Transcoding 7-bit ASCII to another type of ASCII is compatible, but transcoding ASCII to 7-bit ASCII might not be compatible.
The ENCODCOMPAT function specifies the following values:
–1 Source1 is not a valid encoding name.
–2 Source2 is not a valid encoding name.
0 The encodings are not compatible. Transcoding is needed.
1 The encodings are compatible. Transcoding is not needed.
2 A newline character is detected.

Example

The following examples demonstrate the ENCODCOMPAT features:
Statements
Results
/* session encoding is wlatin1 */
isCompat= EncodCompat(“xyz”);
put isValid;
-1
/* session encoding is wlatin1 */
isCompat= EncodCompat (“cp1252”);
put isValid;
1
isCompat= EncodCompat
(“ebcdic1149”,”open_ed-1149”);
put isValid;
2
isCompat= EncodCompat
(“cp1251”,”ebcdic1149”);
put isValid;
0