cs_manage_convert

Description

Installs or retrieves a user-defined character-set conversion routine.

Syntax

CS_RETCODE cs_manage_convert(context, action,
        srctype, srcname, srcnamelen, 
        desttype, destname, destnamelen,
        conv_multiplier, func)
CS_CONTEXT       *context;
CS_INT                 action;
CS_INT                 srctype;
CS_CHAR             *srcname;
CS_INT                 srcnamelen;
CS_INT                 desttype;
CS_CHAR             *destname;
CS_INT                 destnamelen;
CS_INT                  *conv_multiplier;
CS_CONV_FUNC    *func;

Parameters

context

A pointer to a CS_CONTEXT structure.

action

One of the following symbolic values:

Value of action

cs_manage_convert

CS_SET

Installs a conversion routine and conversion multiplier for conversions between the indicated datatypes and character-set names.

CS_GET

Retrieves the current conversion routine and conversion multiplier for the indicated datatypes and character-set names.

CS_CLEAR

Clears the current conversion routine by replacing it with CS-Library’s default conversion routine for the indicated datatypes and character-set names.

srctype

The datatype of the source data for the conversion. In the current version, srctype must be CS_CHAR_TYPE.

srcname

The name of the character set associated with srctype. This name must correspond to the name of a subdirectory within the charsets subdirectory of the Sybase installation directory.

srcnamelen

The length, in bytes, of srcname. If srcname is null-terminated, srcnamelen can be passed as CS_NULLTERM.

desttype

The datatype of the destination data. In the current version, desttype must be CS_CHAR_TYPE.

destname

The name of the destination character set. This name must correspond to the name of a subdirectory within the charsets subdirectory of the Sybase installation directory.

destnamelen

The length, in bytes, of destname. If destname is null-terminated, destnamelen can be passed as CS_NULLTERM.

conv_multiplier

The address of a CS_INT variable. When action is CS_SET, pass *conv_multiplier as the conversion multiplier for the indicated character-set conversion. When action is CS_GET, *conv_multiplier receives the conversion multiplier for the indicated character-set conversion. When action is CS_CLEAR, pass conv_multiplier as NULL.

See “Meaning of the conversion multiplier” for a explanation of how applications use this number.

func

The address of a CS_CONV_FUNC variable, which itself is a pointer to a character-set conversion routine. “Defining a custom character set conversion routine” describes the requirements for coding a custom character-set conversion routine.

If a conversion routine is being installed, *func points to the conversion routine to be installed.

If a conversion routine is being retrieved, cs_manage_convert sets *func to point to the currently installed character-set conversion routine for srcname to destname conversions, or to NULL if no custom routine is installed.

If a conversion routine is being cleared, pass *func as NULL.

Notefunc represents a pointer to a pointer to a function. There are special requirements for passing this parameter. See the example code fragment under “Installing a custom character set conversion routine”.

Returns

cs_manage_convert returns:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

The most common reason for a cs_manage_convert failure is an invalid parameter.

Usage


Character set conversion


Meaning of the conversion multiplier


Defining a custom character set conversion routine

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

Return value

Indicates

CS_SUCCEED

Successful conversion.

CS_TRUNCATED

The conversion resulted in truncation.

CS_MEM_ERROR

A memory allocation failure has occurred.

CS_EBADXLT

Some characters could not be translated.

CS_ENOXLT

The requested translation is not supported.

CS_EDOMAIN

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

CS_EDIVZERO

Division by 0 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 which is not syntactically correct for the destination type.

CS_ESTYLE

The conversion operation was stopped due to a style error.


Installing a custom character set conversion routine

See also

cs_conv_mult, cs_convert, cs_locale, cs_set_convert