Performance issues

Most performance overhead in code-set conversion is a result of either memory management or multibyte-string traversal. However, only if one of the code sets is a multibyte code set does code-set conversion require this overhead to convert correctly. If the code-set conversion is between two single-byte code sets, you can obtain a code-set conversion table and avoid this overhead.

The following sample code uses the ifx_gl_cv_sb2sb_table() function to obtain a code-set conversion table for two single-byte code sets:
void do_codeset_conversion(src, src_codeset, dst,
        dst_codeset)
    unsigned char *src;
    char *src_codeset;
    unsigned char *dst;
    char *dst_codeset;
{
    unsigned char *table;

    if ( ifx_gl_cv_sb2sb_table(dst_codeset,
            src_codeset, &table) == -1 )
      /* Handle Error */

    if ( table != NULL )
        {
        /* Convert in place */
        for ( ; *src != '\0'; src++ ) *src = table[*src];
            dst = src;
        }
    else
       {
       /* Full GLS code-set conversion, which handles
        * multibyte conversions and complex conversions
        * between single-byte code sets */
       ...
       }
}