Skip to content

Commit

Permalink
UTF-32 by definition can't handle characters higher than 0x10FFFF
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 13, 2006
1 parent 10d16a3 commit 1203178
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/stdlib/SDL_iconv.c
Expand Up @@ -669,7 +669,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
case ENCODING_UTF32BE:
{
Uint8 *p = (Uint8 *)dst;
if ( ch > 0x7FFFFFFF ) {
if ( ch > 0x10FFFF ) {
ch = UNKNOWN_UNICODE;
}
if ( dstlen < 4 ) {
Expand All @@ -686,7 +686,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
case ENCODING_UTF32LE:
{
Uint8 *p = (Uint8 *)dst;
if ( ch > 0x7FFFFFFF ) {
if ( ch > 0x10FFFF ) {
ch = UNKNOWN_UNICODE;
}
if ( dstlen < 4 ) {
Expand Down
8 changes: 5 additions & 3 deletions test/testiconv.c
Expand Up @@ -3,7 +3,7 @@

#include "SDL.h"

static SDL_bool testutf16(char *data)
static SDL_bool testutf1632(char *data)
{
Uint32 *p = (Uint32 *)data;
while(*p) {
Expand Down Expand Up @@ -63,8 +63,10 @@ int main(int argc, char *argv[])
size_t len = (widelen(ucs4)+1)*4;
for ( i = 0; i < SDL_arraysize(formats); ++i ) {
if ( (SDL_strncasecmp(formats[i], "UTF16", 5) == 0 ||
SDL_strncasecmp(formats[i], "UTF-16", 6) == 0) &&
!testutf16(ucs4) ) {
SDL_strncasecmp(formats[i], "UTF-16", 6) == 0 ||
SDL_strncasecmp(formats[i], "UTF32", 5) == 0 ||
SDL_strncasecmp(formats[i], "UTF-32", 6) == 0) &&
!testutf1632(ucs4) ) {
continue;
}
test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
Expand Down

0 comments on commit 1203178

Please sign in to comment.