cs_conv_mult

Description

Retrieves the conversion multiplier for converting character data from one character set to another.

Syntax

CS_RETCODE cs_conv_mult(context, 
                         srcloc, 
                         destloc, 
                         conv_multiplier)
 CS_CONTEXT      *context;
 CS_LOCALE         *srcloc;
 CS_LOCALE         *destloc;
 CS_INT                  *conv_multiplier;

Parameters

context

A pointer to a CS_CONTEXT structure.

srcloc

A pointer to the CS_LOCALE structure that describes the source variable’s character set. This parameter cannot be NULL.

destloc

A pointer to the CS_LOCALE structure that describes the destination variable’s character set. This parameter cannot be NULL.

conv_multiplier

A pointer to a CS_INT variable. cs_conv_mult retrieves the conversion multiplier for conversions from the character set indicated by srcloc to the character set indicated by destloc and places it into *conv_multiplier.

Returns

cs_conv_mult returns the following values:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

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

Examples

Example 1

The following code fragment retrieves the conversion multiplier for conversions from the iso_1 character set to the eucjis character set:

#define EXIT_ON_FAIL(context, ret, msg) \
{ if (ret != CS_SUCCEED) \
    { \
      fprintf(stdout,"Fatal error(%ld): %s\n",(long)ret,msg); \
      if (context != (CS_CONTEXT *)NULL) \
      { (CS_VOID)ct_exit(context, CS_FORCE_EXIT); \
        (CS_VOID)cs_ctx_drop(context); } \
      exit(-1); \
    } }

** usa_locale uses the iso_1 character set.
*/
ret = cs_loc_alloc(context, &usa_locale);
EXIT_ON_FAIL(context, ret, "cs_loc_alloc(usa) failed.");
ret = cs_locale(context, CS_SET, usa_locale,
                CS_SYB_CHARSET, "iso_1", CS_NULLTERM, NULL);
EXIT_ON_FAIL(context, ret, "cs_locale(usa, CHARSET) failed.");
/*
 ** japan_locale uses eucjis.
 */
 ret = cs_loc_alloc(context, &japan_locale);
 EXIT_ON_FAIL(context, ret, "cs_loc_alloc(japan) failed.");
ret = cs_locale(context, CS_SET, japan_locale,
                 CS_SYB_CHARSET, "eucjis", CS_NULLTERM, NULL);
 EXIT_ON_FAIL(context, ret, "cs_locale(japan, CHARSET) failed.");
/*
 ** Get the conversion multiplier for iso_1 to eucjis conversions.
 */
 ret = cs_conv_mult(context, 
                    usa_locale, japan_locale, &conv_mult);
 EXIT_ON_FAIL(context, ret, "cs_conv_mult(usa, japan) failed.");
fprintf(stdout, 
         "Conversion multiplier for iso_1 to eucjis is %ld.\n",
         (long)conv_mult);

Usage

See also

cs_convert, cs_locale, cs_manage_convert