Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 7:53 am

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Jul 30, 2011 4:46 am 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
Hello again,

I've just run into another problem. My basic setup is this:

Code:
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

public class TestGame extends StateBasedGame {

   public TestGame() {
      super("éöäü");
   }

   public static void main(String[] args) throws SlickException {
      new AppGameContainer(new TestGame(), 640, 480, false).start();
   }
}


Now, the thing is that I don't get the title "éöäü" for the game window; instead, I get "éöäü". This definitely looks like some kind of encoding issue - is it a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2011 2:10 am 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
I tried to duplicate your problem, but it worked fine. What OS are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2011 5:30 am 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
Oops, I'm sorry, usually I don't forget to include information like that. I'm using Linux Mint 11, Slick Build #274 and LWJGL 2.7.1. As it seems to work fine for you, I guess I'll also try to test some more to see what's going on.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2011 12:23 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
So, I've tried the same thing on a Windows 7 installation (and even another Linux distribution), and it still has the same problem, so I don't think it's an OS problem.

@Mr. Kenkron:
Now I'd actually be curious to find out what setup you're using, because I can't get it to work properly at all.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2011 2:28 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
good point. I have a dell inspiron 1545 running windows 7 professional 64 bit on an intel integrated graphics card. I've been using the nightly build of slick and the 32 bit dll (I don't know why I use 32 bit).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2011 2:06 am 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
I've tried the nightly build on Windows 7 (32 bit) and still, no dice. I'm puzzled as to what's going on - it'd actually be really helpful if more people could test this.

@Mr. Kenkron: If it doesn't bother you, could you perhaps upload a working test project (including the libraries/.dlls you used) so I can run that and see if it changes anything? The reason for all this could still be that I'm just being stupid, so that would be really helpful.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2011 6:30 am 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Tried it with a German Win XP x86 at work, works perfectly. The unicodes are displayed correctly. I should have the newest slick from SVN.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2011 7:06 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
Okay, here's a zip file of the source of an app that works on my computer. http://dl.dropbox.com/u/5171811/TitleTextTest.zip
The title displays "éöäü" for me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 8:27 am 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
@Mr. Kenkron:
Well, that's interesting. Turns out the test you sent me works perfectly fine (even for me), correct title and everything. So I just have to figure out why yours is different... In any case, thank you very much for your help. (Also, that lighting demo thingy looks really nice!)


I guess I'll post back when I figure out what went wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 2:21 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
thanks for the compliment, I spent all wednesday figuring it out, and thought "I just have to do something with this".


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 4:59 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
Okay, I think I finally got it. Mr. Kenkron, your source files were encoded in some variant of ANSI encodings, probably Windows-1252 or ISO-8859-1 (well, you could only tell in the file with the special characters "éöäü", because the rest was just ASCII characters anyway), while I always encode my files in UTF-8.

As soon as I changed my source files' encoding and recompiled, I got the "correct" window title. Now, I don't know a lot about Java's compiled binary format, so I don't quite see why the encoding of the source files matters to the compiled program (because "char" and "java.lang.String" use UTF-16 anyway), but I think it's pretty clear that the window title in Slick/LWJGL doesn't handle Unicode properly.

To everyone who got the "correct" output: I'm pretty sure if you repeat the test with UTF-8 encoded source files, you'll have the same issue as I did.

I suppose all that's missing is an explanation as to why this is happening and how it can be fixed (I'd really like my files to stay in UTF-8).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 5:35 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
wow, I didn't know that java source files had more than one encoding. I'm glad you figured that out.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 7:43 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
javac by default uses "utf-8" as well as many IDEs like Netbeans. While eclipse defaults to platform encoding which leads to this issue.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 8:15 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
@MatthiasM: Yeah, I figured as much. What I still don't really get is why this affects the final programs (because Java should eventually convert everything to UTF-16, right?). Also, what's certain is that we have some kind of library which doesn't accept Unicode, which is pretty annoying.

I've also just found out about the JVM option "-Dfile.encoding". Apparently, even if you used (for example) Windows-1252 when compiling your files, that option also has to be set to "Windows-1252" to get the window title to work properly. However, I don't know how that option works, exactly.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 9:25 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
It's your source code which is wrong - eg you use a stupid encoding for your source code, but the compiler expects UTF8 ==> garbage (or your source code is UTF8 and Eclipse compiles it using the wrong encoding).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group