autogen.sh
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 7232 6f17d930be39
child 10398 165f98326b5c
permissions -rwxr-xr-x
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).
slouken@0
     1
#!/bin/sh
slouken@0
     2
#
slouken@1376
     3
echo "Generating build information using autoconf"
slouken@0
     4
echo "This may take a while ..."
slouken@0
     5
slouken@0
     6
# Regenerate configuration files
slouken@7232
     7
cat acinclude/* >aclocal.m4
slouken@1564
     8
found=false
slouken@1832
     9
for autoconf in autoconf autoconf259 autoconf-2.59
slouken@1564
    10
do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi
slouken@1563
    11
done
slouken@1564
    12
if test x$found = xfalse; then
slouken@1564
    13
    echo "Couldn't find autoconf, aborting"
slouken@1564
    14
    exit 1
slouken@1564
    15
fi
slouken@1380
    16
(cd test; sh autogen.sh)
slouken@0
    17
slouken@0
    18
# Run configure for this platform
slouken@0
    19
echo "Now you are ready to run ./configure"