From: <ny...@us...> - 2007-02-08 14:19:28
|
Revision: 309 http://svn.sourceforge.net/pmplib/?rev=309&view=rev Author: nyaochi Date: 2007-02-08 06:19:22 -0800 (Thu, 08 Feb 2007) Log Message: ----------- The completion of the initial documentation of the UCS-2 library. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char_iconv.c trunk/pmplib/lib/ucs2/ucs2char_win32.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/include/ucs2char.h 2007-02-08 14:19:22 UTC (rev 309) @@ -344,10 +344,39 @@ * @{ */ +/** + * Test whether a USC-2 character is a surrogate-pair character in UTF-16. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2issurrogate(ucs2char_t c); + +/** + * Test whether a USC-2 character is a whitespace character. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2isspace(ucs2char_t c); + +/** + * Test whether a USC-2 character is a numeric character. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2isdigit(ucs2char_t c); + +/** + * Convert a UCS-2 character to lower case. + * @param c The UCS-2 character to be coverted. + * @retval ucs2char_t The resultant UCS-2 character. + */ UCS2API ucs2char_t ucs2lower(ucs2char_t c); + +/** + * Convert a UCS-2 character to upper case. + * @param c The UCS-2 character to be coverted. + * @retval ucs2char_t The resultant UCS-2 character. + */ UCS2API ucs2char_t ucs2upper(ucs2char_t c); /** @@ -607,11 +636,42 @@ * @{ */ +/** + * Convert a UCS-2 string to integer value. + * @param str The pointer to a string. + * @retval int The corresponding integer value. + */ UCS2API int ucs2toi(const ucs2char_t* str); + +/** + * Convert an integer value to UCS-2 string. + * @param value The integer value. + * @param string The pointer to the buffer to receive the string. + * @param radix Radix of the \a value. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); -UCS2API ucs2char_t fputucs2c(ucs2char_t c, FILE *fp); + +/** + * Open a stream from a file. + * @param filename The pointer to the UCS-2 string for the file name. + * @param mode The pointer to the C string for the open mode. + * @retval FILE* The pointer to the opened stream if successful, + * NULL otherwise. + */ UCS2API FILE *ucs2fopen(const ucs2char_t *filename, const char *mode); +/** + * Write a UCS-2 character to a stream. + * @param c The character to be written. + * @param fp The pointer to the output stream. + * @retval int Zero if successful, non-zero otherwise. + */ +UCS2API int fputucs2c(ucs2char_t c, FILE *fp); + + + /** @} */ /** @} */ Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 14:19:22 UTC (rev 309) @@ -241,14 +241,16 @@ } } -ucs2char_t fputucs2c(ucs2char_t c, FILE *fp) +int fputucs2c(ucs2char_t c, FILE *fp) { ucs2char_t ucs2str[2] = {c, 0}; size_t mbs_size = ucs2tombs(NULL, 0, ucs2str, ucs2len(ucs2str)) + 1; char* mbs = (char *)alloca(mbs_size * sizeof(char)); if (mbs) { ucs2tombs(mbs, mbs_size, ucs2str, ucs2len(ucs2str)+1); - fputs(mbs, fp); + return (fputs(mbs, fp) != EOF : 0 ? 1); + } else { + return 1; } } Modified: trunk/pmplib/lib/ucs2/ucs2char_win32.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-08 14:19:22 UTC (rev 309) @@ -105,9 +105,9 @@ } -ucs2char_t fputucs2c(ucs2char_t c, FILE *fp) +int fputucs2c(ucs2char_t c, FILE *fp) { - return (ucs2char_t)fputwc((wchar_t)c, fp); + return (fputwc((wchar_t)c, fp) != WEOF ? 0 : 1); } FILE *ucs2fopen(const ucs2char_t *filename, const char *mode) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |