1.1 --- a/include/SDL_stdinc.h Sun Mar 12 01:47:23 2006 +0000
1.2 +++ b/include/SDL_stdinc.h Mon Mar 13 01:08:00 2006 +0000
1.3 @@ -70,6 +70,9 @@
1.4 #if HAVE_CTYPE_H
1.5 # include <ctype.h>
1.6 #endif
1.7 +#if HAVE_ICONV_H
1.8 +# include <iconv.h>
1.9 +#endif
1.10
1.11 /* The number of elements in an array */
1.12 #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
1.13 @@ -518,6 +521,12 @@
1.14 extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
1.15 #endif
1.16
1.17 +#if HAVE_STRNCASECMP
1.18 +#define SDL_strncasecmp strncasecmp
1.19 +#else
1.20 +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
1.21 +#endif
1.22 +
1.23 #if HAVE_SSCANF
1.24 #define SDL_sscanf sscanf
1.25 #else
1.26 @@ -536,6 +545,32 @@
1.27 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
1.28 #endif
1.29
1.30 +/* The SDL implementation of iconv() returns these error codes */
1.31 +#define SDL_ICONV_ERROR (size_t)-1
1.32 +#define SDL_ICONV_E2BIG (size_t)-2
1.33 +#define SDL_ICONV_EILSEQ (size_t)-3
1.34 +#define SDL_ICONV_EINVAL (size_t)-4
1.35 +
1.36 +#if HAVE_ICONV
1.37 +#define SDL_iconv_t iconv_t
1.38 +#define SDL_iconv_open iconv_open
1.39 +#define SDL_iconv_close iconv_close
1.40 +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
1.41 +#else
1.42 +typedef struct _SDL_iconv_t *SDL_iconv_t;
1.43 +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
1.44 +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
1.45 +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
1.46 +#endif
1.47 +/* This function converts a string between encodings in one pass, returning a
1.48 + string that must be freed with SDL_free() or NULL on error.
1.49 +*/
1.50 +extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
1.51 +#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
1.52 +#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
1.53 +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
1.54 +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
1.55 +
1.56 /* Ends C function definitions when using C++ */
1.57 #ifdef __cplusplus
1.58 }