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 455 - SDL_iconv_string fails on Ubuntu locale...
Summary: SDL_iconv_string fails on Ubuntu locale...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 1.2.11
Hardware: x86 Linux
: P1 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-12 00:03 UTC by Ryan C. Gordon
Modified: 2007-07-12 01:10 UTC (History)
0 users

See Also:


Attachments
Proposed fix. (1.54 KB, patch)
2007-07-12 00:18 UTC, Ryan C. Gordon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan C. Gordon 2007-07-12 00:03:37 UTC
On this Ubuntu system, src/stdlib/SDL_iconv.c's SDL_iconv_string() returns -1, because the LANG environment that getlocale() finds is set to "en_US.UTF-8", which apparently it doesn't like.

This cascades down, causing SDL_WM_SetCaption() to fail. Was this separate from what caused Bug #447?

The full version of the LANG environment variable can look like this:

   fr_CA.utf8@blah

(that's language_REGION.encoding@extrainfo ... UTF-8 French Canadian, in this case.)

Any section of that can apparently be missing. Lots of systems only set "fr" or "fr_CA" or whatnot.

I'm not sure what the "@blah" part is for and I've never seen it set in the wild. UTF-8 can be "UTF-8" or "utf8", apparently.

So I guess we'd have to look for '.' and '@' in LANG and trim out the parts we don't need if they exist, and maybe convert "utf8" to "UTF-8" if iconv doesn't handle it.

--ryan.
Comment 1 Ryan C. Gordon 2007-07-12 00:03:55 UTC
Flagging as P1 for the 1.2.12 release, since this basically breaks SDL_WM_SetCaption() on every modern Linux box.  :/

--ryan.

Comment 2 Ryan C. Gordon 2007-07-12 00:18:47 UTC
Created attachment 224 [details]
Proposed fix.


Here's a shot at fixing this. I'm not sure if this is the right approach, or covers all reasonable strings, but it works here.

--ryan.
Comment 3 Ryan C. Gordon 2007-07-12 00:19:14 UTC
Tossing to Sam. Please apply that patch if you think it's reasonable.

--ryan.

Comment 4 Sam Lantinga 2007-07-12 00:21:39 UTC
I have another idea.  Apparently passing "" to iconv_open indicates the locale dependent encoding.  I'll play with this a bit.
Comment 5 Sam Lantinga 2007-07-12 00:29:55 UTC
This is fixed in revision 3234, thanks!
Comment 6 Sam Lantinga 2007-07-12 01:08:34 UTC
I applied your patch to the built-in version of iconv_open().  Thanks!

Comment 7 Sam Lantinga 2007-07-12 01:09:45 UTC
BTW, the semantics of strstr are really dangerous.  As you can see by the bug in your patch... :)
But I guess it's the best you can do without being able to have both const and non-const versions of a function.
Comment 8 Sam Lantinga 2007-07-12 01:10:32 UTC
Semantics of strchr even. :)