Writing a custom conversion routine

A custom character set conversion routine is defined as follows:

CS_RETCODE convfunc(context, srcfmt, srcdata,
               destfmt, destdata, destlen)
 CS_CONTEXT        *context;
 CS_DATAFMT        *srcfmt;
 CS_VOID               *srcdata;
 CS_DATAFMT       *destfmt;
 CS_VOID              *destdata;
 CS_INT                 *destlen;

where:

cs_config is the only CS-Library, Client-Library, or Server-Library routine that can be called from within a custom conversion routine.

CS-Library raises a CS-Library error if the custom routine returns any value other than CS_SUCCEED. The type of error that CS-Library raises depends on the value that the custom routine returns.

Table 4-2 lists the legal return values for a custom conversion routine:

Table 4-2: Return values for a custom conversion routine

Return value

Indicates

CS_SUCCEED

The conversion is successful.

CS_TRUNCATED

The conversion resulted in truncation.

CS_MEM_ERROR

A memory allocation failure has occurred.

CS_EBADXLT

Some characters could not be converted.

CS_ENOXLT

The requested conversion is not supported.

CS_EDOMAIN

The source value is outside the domain of legal values for the datatype.

CS_EDIVZERO

Division by zero is not allowed.

CS_EOVERFLOW

The conversion resulted in overflow.

CS_EUNDERFLOW

The conversion resulted in underflow.

CS_EPRECISION

The conversion resulted in loss of precision.

CS_ESCALE

An illegal scale value was encountered.

CS_ESYNTAX

The conversion resulted in a value that is not syntactically correct for the destination type.

CS_ESTYLE

The conversion operation was stopped due to a style error.