We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2786 - [patch] "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead
Summary: [patch] "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: main (show other bugs)
Version: HG 2.1
Hardware: All Windows (All)
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-16 11:55 UTC by Jonas Kulla
Modified: 2014-12-05 13:39 UTC (History)
0 users

See Also:


Attachments
patch (505 bytes, patch)
2014-11-16 11:55 UTC, Jonas Kulla
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Kulla 2014-11-16 11:55:44 UTC
Created attachment 1933 [details]
patch

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).
Comment 1 Sam Lantinga 2014-11-28 12:52:23 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/a761913e5e91
Comment 2 Jonas Kulla 2014-12-05 13:39:36 UTC
Thank you.