### cstoccsid -- Determine Coded Character Set ID for Code Page Name

Format

>     #include <iconv.h>
>     CCSID cstoccsid(const char *codeset);

Language Level: Extension
cstoccsid returns the corresponding CCSID of the code page specified by the codeset parameter. CCSIDs are registered IBM coded character set IDs.

cstoccsid looks for the ccsid.tbl in the iconv subdirectory in one of the paths specified by the LOCPATH environment variable.

Return Value
If the CCSID is returned successfully, then cstoccsid returns the numeric ccsid that corresponds to the specified codeset name. If the return is unsuccessful, cstoccsid returns 0.

The value of errno may be set to:

ENOENT | The ccsid table (file ccsid.tbl) cannot be opened.
EOS2ERR | I/O error opening or reading the ccsid file.

Example
The following example uses the cstoccsid function to determine the ccsid of the active code page. The call to setlocale will load a locale bound to the active code page. nl_langinfo is then used to retrieve the code page name.

    #include <stdio.h>
    #include <locale.h>
    #include <nl_types.h>
    #include <langinfo.h>
    #include <iconv.h>

    int main(int argc, char *argv[], char *envp[])
    {
       char *cs;

       setlocale(LC_ALL,"");

       cs = nl_langinfo(CODESET);
       printf("%s %i \n",cs,cstoccsid(cs));

       return 0;

       /*********************************************************
          The output will be the ccsid of the active code page,
          eg. "IBM-850 850".
       *********************************************************/
    }

ccsidtocs -- Determine Code Page Name for Coded Character Set ID