UTF-32 by definition can't handle characters higher than 0x10FFFF
authorSam Lantinga <slouken@libsdl.org>
Mon, 13 Mar 2006 01:16:16 +0000
changeset 1502d403a39389da
parent 1501 73dc5d39bbf8
child 1503 5e4dad24a5de
UTF-32 by definition can't handle characters higher than 0x10FFFF
src/stdlib/SDL_iconv.c
test/testiconv.c
     1.1 --- a/src/stdlib/SDL_iconv.c	Mon Mar 13 01:08:00 2006 +0000
     1.2 +++ b/src/stdlib/SDL_iconv.c	Mon Mar 13 01:16:16 2006 +0000
     1.3 @@ -669,7 +669,7 @@
     1.4  		    case ENCODING_UTF32BE:
     1.5  			{
     1.6  				Uint8 *p = (Uint8 *)dst;
     1.7 -				if ( ch > 0x7FFFFFFF ) {
     1.8 +				if ( ch > 0x10FFFF ) {
     1.9  					ch = UNKNOWN_UNICODE;
    1.10  				}
    1.11  				if ( dstlen < 4 ) {
    1.12 @@ -686,7 +686,7 @@
    1.13  		    case ENCODING_UTF32LE:
    1.14  			{
    1.15  				Uint8 *p = (Uint8 *)dst;
    1.16 -				if ( ch > 0x7FFFFFFF ) {
    1.17 +				if ( ch > 0x10FFFF ) {
    1.18  					ch = UNKNOWN_UNICODE;
    1.19  				}
    1.20  				if ( dstlen < 4 ) {
     2.1 --- a/test/testiconv.c	Mon Mar 13 01:08:00 2006 +0000
     2.2 +++ b/test/testiconv.c	Mon Mar 13 01:16:16 2006 +0000
     2.3 @@ -3,7 +3,7 @@
     2.4  
     2.5  #include "SDL.h"
     2.6  
     2.7 -static SDL_bool testutf16(char *data)
     2.8 +static SDL_bool testutf1632(char *data)
     2.9  {
    2.10  	Uint32 *p = (Uint32 *)data;
    2.11  	while(*p) {
    2.12 @@ -63,8 +63,10 @@
    2.13  		size_t len = (widelen(ucs4)+1)*4;
    2.14  		for ( i = 0; i < SDL_arraysize(formats); ++i ) {
    2.15  			if ( (SDL_strncasecmp(formats[i], "UTF16", 5) == 0 ||
    2.16 -			      SDL_strncasecmp(formats[i], "UTF-16", 6) == 0) &&
    2.17 -			      !testutf16(ucs4) ) {
    2.18 +			      SDL_strncasecmp(formats[i], "UTF-16", 6) == 0 ||
    2.19 +			      SDL_strncasecmp(formats[i], "UTF32", 5) == 0 ||
    2.20 +			      SDL_strncasecmp(formats[i], "UTF-32", 6) == 0) &&
    2.21 +			      !testutf1632(ucs4) ) {
    2.22  				continue;
    2.23  			}
    2.24  			test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);