premake/patches/711.patch
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 7925 f090a47eb7f7
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).
icculus@7925
     1
# HG changeset patch
icculus@7925
     2
# User Ben Henning
icculus@7925
     3
# Date 1376453463 25200
icculus@7925
     4
#      Tue Aug 13 21:11:03 2013 -0700
icculus@7925
     5
# Node ID a5f8b4f709722222e02fa481873d76ad25255e09
icculus@7925
     6
# Parent  8b24d45e6a5d717876a7b32b64e99043c95328e5
icculus@7925
     7
Implemented Xcode recognizing bitmap and wave files as resources, plus properly
icculus@7925
     8
set their types recognizable by Xcode itself.
icculus@7925
     9
icculus@7925
    10
diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua
icculus@7925
    11
--- a/src/actions/xcode/xcode_common.lua
icculus@7925
    12
+++ b/src/actions/xcode/xcode_common.lua
icculus@7925
    13
@@ -32,6 +32,8 @@
icculus@7925
    14
 			[".nib"] = "Resources",
icculus@7925
    15
 			[".xib"] = "Resources",
icculus@7925
    16
 			[".icns"] = "Resources",
icculus@7925
    17
+			[".bmp"] = "Resources",
icculus@7925
    18
+			[".wav"] = "Resources",
icculus@7925
    19
 		}
icculus@7925
    20
 		return categories[path.getextension(node.name)]
icculus@7925
    21
 	end
icculus@7925
    22
@@ -85,6 +87,8 @@
icculus@7925
    23
 			[".strings"]   = "text.plist.strings",
icculus@7925
    24
 			[".xib"]       = "file.xib",
icculus@7925
    25
 			[".icns"]      = "image.icns",
icculus@7925
    26
+			[".bmp"]       = "image.bmp",
icculus@7925
    27
+			[".wav"]       = "audio.wav",
icculus@7925
    28
 		}
icculus@7925
    29
 		return types[path.getextension(node.path)] or "text"
icculus@7925
    30
 	end