Slick Forums

Discuss the Slick 2D Library
It is currently Fri Dec 06, 2019 1:05 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Mon Aug 01, 2011 1:21 am 
Offline

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

as I haven't yet received an answer in my other thread (http://slick.javaunlimited.net/viewtopic.php?t=3593&sid=cd81bd0a60ef65a99b309fab750131cb), I'm going to assume that my observation in said thread is a bug.

To recapitulate, if you set a game container's title (a subclass of StateBasedGame in my example) to a string with special characters, e.g. "éöäü", the window title will display garbage when the application is run. For some reason, there seems to be an encoding issue.


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

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
I'm updating this thread with the things found out in the other thread:

Whether the window title outputs the correct string depends on the character encoding used for running the program. See the following example program, which consists of one class:
Code:
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

public class TestGame extends StateBasedGame {

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

   public TestGame() {
      super("éöäü");
      System.out.println("éöäü");
   }

   @Override
   public void initStatesList(GameContainer container) throws SlickException {
   }

}


The libraries slick.jar (Build #274) and lwjgl.jar (version 2.7.1) as well as the corresponding native libraries were used.

If the compiled program is run with the following command (libraries are in a directory "lib", .class files in "bin"):
Code:
java -cp bin:"lib/*" -Djava.library.path=lib TestGame

The console output from the "System.out.println()" call is correct, while the window title displays "éöäü".
However, if it is run with:
Code:
java -cp bin:"lib/*" -Djava.library.path=lib -Dfile.encoding=Windows-1252 TestGame

The console just displays question marks (at least for me). However, the window title displays "éöäü".

Apparently, some library in Slick or LWJGL doesn't accept Unicode and only works with ANSI encodings. However, I can't exactly tell what's going on without further knowledge of Slick, LWJGL or the "file.encoding" setting. Is there any chance that this could be fixed if it is a Slick bug? Or should I turn to the LWJGL developers with this?


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

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
It is not a library problem. You have the file encoding of your source file wrong (probably because Eclipse has a brain dead default of using system encoding instead of UTF8).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 10:08 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
MatthiasM wrote:
It is not a library problem. You have the file encoding of your source file wrong (probably because Eclipse has a brain dead default of using system encoding instead of UTF8).

No. I'm not even using Eclipse. I've viewed my source code in a hex editor, and it's definitely UTF-8 - the string "éöäü" consists of the bytes "0xC3 0xA9 0xC3 0xB6 0xC3 0xA4 0xC3 0xBC" in the file, which is indeed correct UTF-8.

But what happens if you interpret those bytes as Windows-1252 or ISO 8859-1? Exactly, the result is "éöäü", which is what the window title does. I can upload a sample project if necessary.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 10:51 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
That is done while compiling - so you need to ensure that javac and your source code match.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2011 11:01 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
@MatthiasM:
I did! This is how I compiled the file:
Code:
javac -classpath "lib/*" -d bin -encoding UTF-8 src/TestGame.java

There were no compiler warnings or errors.

I have uploaded a test project here. Running the "TestGame" class with the two commands above produces the results I have described.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2011 3:04 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
Well, so, once again, is there any advice on how I should proceed with this issue? MatthiasM might not have agreed with me (so far, at least), but I have no doubts that this is a bug somewhere.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2011 9:32 am 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 585
Do try with the latest nightly builds of LWJGL. This because ofthis recent fix.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2011 6:24 am 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
@kappa:

The latest build does indeed seem to get rid of the issue under Windows. Unfortunately, it doesn't seem to affect Linux (I've tested it and the changelog explicitly specifies Windows). Anyway, at least that confirms that it was/is an LWJGL bug. Thank you very much for that hint!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2011 12:00 pm 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 585
Socob wrote:
@kappa:

The latest build does indeed seem to get rid of the issue under Windows. Unfortunately, it doesn't seem to affect Linux (I've tested it and the changelog explicitly specifies Windows). Anyway, at least that confirms that it was/is an LWJGL bug. Thank you very much for that hint!


should be fixed on linux too now, try next nightly build of lwjgl.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2011 12:46 pm 
Offline

Joined: Fri Jul 29, 2011 9:26 pm
Posts: 23
Location: Germany
@kappa:
That was fast! All solved now, thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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