Mercurial > sdl-ios-xcode
annotate src/video/ps3/SDL_ps3yuv_c.h @ 4388:1524d3237820 SDL-1.2
Fixed bug #896
John Popplewell 2009-12-08 23:05:50 PST
Originally reported by AKFoerster on the mailing list.
Error decoding UTF8 Russian text to UTF-16LE on Windows, but specifically on
platforms without iconv support (the default on Windows).
Valid UTF8 characters are flagged as being overlong and then substituted by the
UNKNOWN_UNICODE character.
After studying the testiconv.c example program, reading the RFCs and putting
some printf statements in SDL_iconv.c the problem is in a test for 'Maximum
overlong sequences', specifically 4.2.1, which is carried out by the following
code:
} else if ( p[0] >= 0xC0 ) {
if ( (p[0] & 0xE0) != 0xC0 ) {
/* Skip illegal sequences
return SDL_ICONV_EILSEQ;
*/
ch = UNKNOWN_UNICODE;
} else {
if ( (p[0] & 0xCE) == 0xC0 ) { <<<<<<<< here
overlong = SDL_TRUE;
}
ch = (Uint32)(p[0] & 0x1F);
left = 1;
}
} else {
Here is the 2-byte encoding of a character in range 00000080 - 000007FF
110xxxxx 10xxxxxx
The line in question is supposed to be checking for an overlong sequence which
would be less than
11000001 10111111
which should be represented as a single byte.
BUT, the mask value (0xCE) is wrong, it isn't checking the top-most bit:
11000001 value
11001110 mask (incorrect)
^
and should be (0xDE):
11000001 value
11011110 mask (correct)
making the above code:
} else if ( p[0] >= 0xC0 ) {
if ( (p[0] & 0xE0) != 0xC0 ) {
/* Skip illegal sequences
return SDL_ICONV_EILSEQ;
*/
ch = UNKNOWN_UNICODE;
} else {
if ( (p[0] & 0xDE) == 0xC0 ) { <<<<<<<< here
overlong = SDL_TRUE;
}
ch = (Uint32)(p[0] & 0x1F);
left = 1;
}
} else {
I can supply a test program and/or a patch if required,
best regards,
John Popplewell
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Dec 2009 08:00:57 +0000 |
parents | 3b8ac3d311a2 |
children |
rev | line source |
---|---|
4165 | 1 /* |
2 * SDL - Simple DirectMedia Layer | |
3 * CELL BE Support for PS3 Framebuffer | |
4 * Copyright (C) 2008, 2009 International Business Machines Corporation | |
5 * | |
6 * This library is free software; you can redistribute it and/or modify it | |
7 * under the terms of the GNU Lesser General Public License as published | |
8 * by the Free Software Foundation; either version 2.1 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
19 * USA | |
20 * | |
21 * Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com> | |
22 * Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com> | |
23 * SPE code based on research by: | |
24 * Rene Becker | |
25 * Thimo Emmerich | |
26 */ | |
27 | |
28 #include "SDL_config.h" | |
29 | |
30 #ifndef _SDL_ps3yuv_h | |
31 #define _SDL_ps3yuv_h | |
32 | |
33 /* This is the PS3 implementation of YUV video overlays */ | |
34 | |
35 #include "SDL_video.h" | |
36 | |
37 extern SDL_Overlay *PS3_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display); | |
38 extern int PS3_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst); | |
39 extern int PS3_LockYUVOverlay(_THIS, SDL_Overlay *overlay); | |
40 extern void PS3_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay); | |
41 extern void PS3_FreeYUVOverlay(_THIS, SDL_Overlay *overlay); | |
42 | |
43 #endif /* _SDL_ps3yuv_h */ | |
44 |