Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE int32_t U_EXPORT2 u_fsetcodepage ( const char *  codepage,
UFILE file 
)

Set the codepage in which data will be written to and read from the UFILE. All Unicode data written to the UFILE will be converted to this codepage before it is written to the underlying FILE*. It it generally a bad idea to mix codepages within a file. This should only be called right after opening the UFile, or after calling u_frewind.

Parameters:
codepage The codepage in which data will be written to and read from the file. For example "latin-1" or "ibm-943". A value of NULL means the default codepage for the UFILE's current locale will be used.
file The UFILE to set.
Returns:
0 if successful, otherwise a negative number.
See also:
u_frewind ICU 3.0

Definition at line 288 of file ufile.c.

References U_SUCCESS, and U_ZERO_ERROR.

{
    UErrorCode status = U_ZERO_ERROR;
    int32_t retVal = -1;

    /* We use the normal default codepage for this system, and not the one for the locale. */
    if ((file->str.fPos == file->str.fBuffer) && (file->str.fLimit == file->str.fBuffer)) {
        ucnv_close(file->fConverter);
        file->fConverter = ucnv_open(codepage, &status);
        if(U_SUCCESS(status)) {
            retVal = 0;
        }
    }
    return retVal;
}


Generated by  Doxygen 1.6.0   Back to index