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 2557

Summary: SDL_iconv's UCS-#-INTERNAL encodng string is incorrect
Product: SDL Reporter: Edward Rudd <urkle>
Component: *don't know*Assignee: Edward Rudd <urkle>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: 2.0.3   
Hardware: x86_64   
OS: Linux   

Description Edward Rudd 2014-05-21 15:52:08 UTC
In the non-iconv code path the UCS native encoding is specified as UCS-4-INTERNAL and UCS-2-INTERNAL in the SDL_iconv.c source.  Likewise in the SDL_stdinc.h the two "helper" macros also use this UCS-#-INTERNAL name.

However, in the testiconv.c  USC-# is simply used.  This is the correct name that libiconv would use.
Comment 1 Edward Rudd 2014-05-22 02:01:01 UTC
OK.. upon further testing USC-4 in iconv == USC-4BE on a LE system..  UGH!.

So maybe we need to add in a wrapping for SDL_iconv to translate USC-4-INTERNAL to the right thing when backed by iconv too?
Comment 2 Sam Lantinga 2014-06-22 03:18:01 UTC
What exactly is the problem?

I don't think there was any specific reason for using those, if there's an issue I think the encoding can be changed.
Comment 3 Edward Rudd 2015-02-06 18:33:50 UTC
The issue is the SDL_stdinc.h has some macros that use UCS-2-INTERNAL and UCS-4-INTERNAL which are only defined on Mac OS X's iconv and not on Linux's iconv.  UCS-#LE and UCS-#BE are both defined (for big endian and little endian).  So we really should add some code in the SDL_iconv routine to "map" UCS-#-INTERNAL to the correct more portable encoding.   I'll write up a patch for this..  (as I ran into this in another game port and it BIT me in the rear)
Comment 4 Ryan C. Gordon 2015-02-19 06:32:14 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
Comment 5 Ryan C. Gordon 2015-04-07 04:57:56 UTC
(sorry if you get a lot of copies of this email, I'm marking several bugs at once)

Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship.

(Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.)

--ryan.
Comment 6 Sam Lantinga 2015-05-28 17:10:11 UTC
Edward, go ahead and submit a fix for this when you have a chance.

Thanks!
Comment 7 Sam Lantinga 2017-08-14 13:05:34 UTC
Edward, can you please submit your patch?

Thanks!
Comment 8 Sylvain 2018-11-05 09:55:27 UTC
Still existing on linux.

For instance SDL_ttf/showfont fails when using option "-unicode".
because "SDL_iconv_utf8_ucs2(message)" returns NULL.

As said, replacing
#define SDL_iconv_utf8_ucs2(S)      (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
by
#define SDL_iconv_utf8_ucs2(S)      (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)

seems to solve the issue as a workaround