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:
context is a pointer to a CS_CONTEXT structure.
srcfmt is a pointer to a CS_DATAFMT structure describing the source data. srcfmt→maxlength describes the actual length, in bytes, of the source data.
srcdata is a pointer to the source data.
destfmt is a pointer to a CS_DATAFMT structure describing the destination data. destfmt→maxlength describes the actual length, in bytes, of the destination data space.
destdata is a pointer to the destination data space.
destlen is a pointer to an integer. If the conversion is successful, the custom routine should set *destlen to the number of bytes placed in *destdata.
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. The following table lists the legal 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. |