/* * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * Copyright (C) 2008 - Yung-Jang Lee * * This file must be used under the terms of the CeCILL. * This source file is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * */ /*--------------------------------------------------------------------------*/ #ifndef __LOCALETOUTF_H__ #define __LOCALETOUTF_H__ #ifdef __cplusplus extern "C" { #endif #include /** * get characters encoding from system locale language setting. * @param[in] lang system locale language setting in lang_contry.charset or lang_contry * format (e.g., en_US, zh_TW.CP950, zh_CN.UTF-8) * @return character encoding(e.g., "CP950", "UTF-8", "GB2312" ."ISO-8859-5") */ char *getEncoding(char *lang); /** * Open a pair of ICONV converter, one from system locale encoding to UTF8 encoding, the other from UTF8 to system locale. * * @param[in] encoding system locale (e.g. "CP950", "UTF-8", "GB2312" ."ISO-8859-5") */ void openCharEncodingConverter(char *encoding); /** * Close pair of ICONV converter, opened by openCharEncodingConverter. */ void closeCharEncodingConverter(); /** * Convert from locale to UTF-8. The converted UTF-8 string * is returened by a pointer. * * Return string point to a fixed buffer, users don't need to free theis pointer. But data * will be overwritten after next converting. * * @param LocleText string in system locale encoding * @return string in UTF8 encoding. * */ char* localeToUTF(char* LocleText) ; /** * Convert from UTF-8 to locale . The converted locale string * is returened by a pointer. * * Return string point to a fixed buffer, users don't need to free theis pointer. But data * will be overwritten after next converting. * * @param LocleText * @return string in system locale encoding. */ char* UTFToLocale(char* UTFText) ; /** * Convert multiple lines of string from locale to UTF-8. The converted UTF-8 strings * are returened by a vector of pointer. * * Return string point to a fixed buffer, users don't need to free theis pointer. But data * will be overwritten after next converting. * * * @param lines * @param nbLine */ char** localeToUTFVec(char** lines,int nbLine) ; /** * Convert multiple lines of string from UTF-8 to locale. The converted locale encoding strings * are returened by a vector of pointer. * * Return string point to a fixed buffer, users don't need to free theis pointer. But data * will be overwritten after next converting. * * * @param lines * @param nbLine */ char** UTFToLocaleVec(char** stringVec,int nbLine) ; /** * A wrap of libintl's gettext. * In Java console mode it return string in UTF8 encoding, * in terminal mode it return in system locale encoding. * Use for sned message to Java console or shell terminal. */ char *_GETTEXT(const char* msgid); /** * A wrap of libintl's gettext. * This version always return string in UTF8 encoding. Use for send message to Java graphics or GUI. */ char *_guiGETTEXT(const char* msgid); /** * Read next UTF character from a UTF stream. * * @param[in] UTFstream a UTF stream. * @param[in] size size in bytes of the UTF character, a 1 to 4 ineger value. * @return character a null ended byte stream represent the UTF character. */ char* readNextUTFChar(char* UTFstream,int* size); /** * Set an internal boolean value for UTF output encoding from a file handle. * @param[in] fp File handle for current output. */ void checkOutputEncoding(FILE *fp); /** * Return true if current output encoding is in UTF encoding, otherwise return FALSE. */ BOOL isOutputInUTF(); #ifdef __cplusplus } #endif #endif /*--------------------------------------------------------------------------*/