ifx_gl_cv_sb2sb_table - returns the single-byte conversion table from the scrcs code set to the dstcodeset code set

SYNOPSIS


#include <ifxgls.h>
int ifx_gl_cv_sb2sb_table(char *dstcodeset, char *srccodeset, unsigned char **array)

DESCRIPTION

If the codeset conversion, from srccodeset to dstcodeset, converts from a single-byte codeset to another single-byte codeset where there are no substitution conversions, then this function sets array to an array of 256 unsigned chars which represent the conversion. If the codeset conversion is not of this form, then this function sets array to NULL.

The codesets, srccodeset and dstcodeset, may be locale specifiers (for example, "de_de.8859-1" or "ja_jp.ujis") or code set names found in the file $INFORMIXDIR/gls/cmX/registry (for example, "8859-1" or "ujis"). The macro, IFX_GL_PROC_CS, may be passed as srccodeset or dstcodeset to specify the code set of the current processing locale. Depending on the context, the value of IFX_GL_PROC_CS is based on either the client's environment, or the database which the server is currently accessing.

RETURN VALUES

Returns 0 upon success and sets the array argument to an array of 256 unsigned chars, or NULL if the code sets are not of the above form. -1 is returned if an error occurs.

ERRORS

If an error has occurred, this function returns -1 and sets ifx_gl_lc_errno() to one of the following,
[IFX_GL_FILEERR]
Retrieving the conversion information for the specified codesets failed. This may be due to invalid codeset names, a missing registry file, a missing codeset conversion object file or one with an incorrect format, or a lack of memory for the codeset conversion object.

EXAMPLES

This function can be used to optimize codeset conversion in the following way:
       void
       do_codeset_conversion(src, srccodeset, dst, dstcodeset)
           unsigned char *src;
           char *srccodeset;
           unsigned char *dst;
           char *dstcodeset;
       {
           unsigned char *table;

           if ( ifx_gl_cv_sb2sb_table(dstcodeset, srccodeset, &table) == -1 )
	       /* Handle Error */

           if ( table != NULL )
               {
               /* Convert in place */
               for ( ; *src != '\0'; src++ ) *src = table[*src];
               dst = src;
               }
           else 
               {
               /* Full GLS codeset conversion, which will handle
                  multi-byte conversions and complex conversions
                  between single-byte codesets
                */
               }
       }

SEE ALSO

ifx_gl_cv_mconv() ifx_gl_conv_needed() ifx_gl_cv_outbuflen() IFX_GL_PROC_CS

ACKNOWLEDGEMENT

Portions of this description were derived from the X/Open CAE Specification: "System Interfaces and Headers, Issue 4"; X/Open Document Number: C202; ISBN: 1-872630-47-2; Published by X/Open Company Ltd., U.K.