test/testautomation_suites.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 8645 d69fdbefeecf
permissions -rw-r--r--
Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead

Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
aschiffler@6756
     1
/**
aschiffler@6756
     2
 * Reference to all test suites.
aschiffler@6756
     3
 *
aschiffler@6756
     4
 */
aschiffler@6756
     5
aschiffler@6756
     6
#ifndef _testsuites_h
aschiffler@6756
     7
#define _testsuites_h
aschiffler@6756
     8
aschiffler@6756
     9
#include "SDL_test.h"
aschiffler@6756
    10
gabomdq@7663
    11
/* Test collections */
aschiffler@6772
    12
extern SDLTest_TestSuiteReference audioTestSuite;
aschiffler@6760
    13
extern SDLTest_TestSuiteReference clipboardTestSuite;
aschiffler@6800
    14
extern SDLTest_TestSuiteReference eventsTestSuite;
aschiffler@6800
    15
extern SDLTest_TestSuiteReference keyboardTestSuite;
jorgen@6866
    16
extern SDLTest_TestSuiteReference mainTestSuite;
slouken@7216
    17
extern SDLTest_TestSuiteReference mouseTestSuite;
slouken@7216
    18
extern SDLTest_TestSuiteReference pixelsTestSuite;
aschiffler@6756
    19
extern SDLTest_TestSuiteReference platformTestSuite;
aschiffler@6757
    20
extern SDLTest_TestSuiteReference rectTestSuite;
aschiffler@6763
    21
extern SDLTest_TestSuiteReference renderTestSuite;
aschiffler@6760
    22
extern SDLTest_TestSuiteReference rwopsTestSuite;
slouken@7216
    23
extern SDLTest_TestSuiteReference sdltestTestSuite;
slouken@7216
    24
extern SDLTest_TestSuiteReference stdlibTestSuite;
aschiffler@6773
    25
extern SDLTest_TestSuiteReference surfaceTestSuite;
aschiffler@6800
    26
extern SDLTest_TestSuiteReference syswmTestSuite;
slouken@7216
    27
extern SDLTest_TestSuiteReference timerTestSuite;
aschiffler@6800
    28
extern SDLTest_TestSuiteReference videoTestSuite;
aschiffler@8645
    29
extern SDLTest_TestSuiteReference hintsTestSuite;
aschiffler@6756
    30
gabomdq@7663
    31
/* All test suites */
aschiffler@6756
    32
SDLTest_TestSuiteReference *testSuites[] =  {
slouken@7191
    33
    &audioTestSuite,
slouken@7191
    34
    &clipboardTestSuite,
slouken@7191
    35
    &eventsTestSuite,
slouken@7191
    36
    &keyboardTestSuite,
slouken@7191
    37
    &mainTestSuite,
slouken@7216
    38
    &mouseTestSuite,
slouken@7216
    39
    &pixelsTestSuite,
slouken@7191
    40
    &platformTestSuite,
slouken@7191
    41
    &rectTestSuite,
slouken@7191
    42
    &renderTestSuite,
slouken@7191
    43
    &rwopsTestSuite,
slouken@7216
    44
    &sdltestTestSuite,
slouken@7216
    45
    &stdlibTestSuite,
slouken@7191
    46
    &surfaceTestSuite,
slouken@7191
    47
    &syswmTestSuite,
slouken@7216
    48
    &timerTestSuite,
slouken@7191
    49
    &videoTestSuite,
aschiffler@8645
    50
    &hintsTestSuite,
slouken@7191
    51
    NULL
aschiffler@6756
    52
};
aschiffler@6756
    53
aschiffler@6756
    54
#endif