Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / [Solved] Gosu and french
- - By Nanaya Date 2013-03-02 01:54

When I try to use special french caracters with gosu, it doesn't work (à, À, é,è,ê, É, È, Ê, ô, Ô, etc.).
Is there any solution?

I'm working with ruby 1.9.3, and gous 0.7.45 (with aptana studio 3).


Parent - - By lol_o2 Date 2013-03-02 08:59
As I know, Ruby doesn't support any Unicode (so I have the same with ą, ę, ó, ż ,ź ł)
I think it's going to be fixed in Ruby 2.0, but maybe there's some gem for this already.
Parent - By jlnr (dev) Date 2013-03-02 09:24
I am German, there is no way Ruby/Gosu would not support our beloved Umlauts äöüß ;)
Parent - - By jlnr (dev) Date 2013-03-02 09:23
You have to make sure that you save your files as UTF-8 (not sure how to do this in Aptana Studio), and in Ruby 1.9.x (but not 1.8 or 2.0), you have to start every file with the following comment: # Encoding: UTF-8.

If you dig deep enough into the Gosu Showcase, I think there is even a game that uses Thai :)
Parent - - By Nanaya Date 2013-03-02 17:49
There's no way because no one "smart" and "brave" enough tried to fix it, did you mean ?
Your trick work perfectly (Aptana wasn't a problem). Unfotunatly, I can't put "ç". Programm doesn't freeze, juste stop where it is (wich means that I don't have any error message).
In ruby 1.9.3 for now, should I move on ruby 2.0.0?
Parent - By jlnr (dev) Date 2013-03-03 02:06
Gosu does not yet work with Ruby 2.0.0 (at least not on Windows).

This is not a trick :) This is how Unicode in Ruby 1.9 works. I'll post a screenshot and minimal script from my other computer...
Parent - - By jlnr (dev) Date 2013-03-03 02:09
Here's a short test program that uses the ç character - tested on Windows 7 with Ruby 1.9.3 and Gosu 0.7.45. Are you sure Aptana is saving the file as UTF-8? Can you post a short Ruby script that shows the problem?
Attachment: french-test.rb (650B)
Parent - - By Nanaya Date 2013-03-03 21:58
Well, the problem is else where (after your post, I retry) : when I use the command gets.chomp in order to get the selected language, I tape this : "français", and it's considered as this : "français". Don't get why.
If I juste set the @language var as "français" (before running the program), then, everthing goes fine.
Quite annoying.
Parent - By jlnr (dev) Date 2013-03-04 23:00
Looks like an encoding problem. What is the .encoding of the string? I think it may be UTF-8 but with the wrong .encoding, and when Gosu converts it to UTF-8 it gets converted once again?

It should be like this:

1.9.3p362 :001 > x = gets.chomp
=> "français"
1.9.3p362 :002 > x.encoding
=> #<Encoding:UTF-8>
Parent - - By jlnr (dev) Date 2013-03-04 23:03
...Looking at the code, I am not sure why I call force_encoding on the string instead of encode internally.

Can please you try gets.chomp.encode("UTF-8") as a workaround?
Parent - - By Nanaya Date 2013-03-05 00:02
When I  don't touch to anything, I get this : Windows-1252 (français) as encoding type. If I use .encode("UTF-8"), the answer is UTF-8, but "français" still isn't recognized : français. It's worse. But, with force_encoding, I get this : français. And UTF-8 as answer.
The other stuff (ÀÁÄÂ, etc.) don't work either.
Parent - By jlnr (dev) Date 2013-03-06 00:51
I think you should contact Aptana support and suggest that they use UTF-8 for everything, especially now that it is the default encoding in Ruby 2.0. I am still not sure if Aptana or Gosu is buggy, but if the whole thing was UTF-8 from start to finish, nothing could possibly break.
Parent - - By Dahrkael Date 2013-03-05 13:15
does the text.unpack('C*').pack('U*') still work?
Parent - - By Nanaya Date 2013-03-05 13:28 Edited 2013-03-05 17:50
Hi, here my resulte with this @language=gets.chomp.unpack('C*').pack('U*') => français (type), français (as result), still UTF-8.
(I use @ just to be sure it won't change, and work what ever happens)

Well, I've tried something else : using the program without my IDE. It's work with no problem.
In fact, in the IRB, it look like this : français => français. But, if I ask  to put (puts) the x value, I got this : français. Finally, in my own program, itself, français -> français.
Why is that hard to get a good IDE...
Parent - - By rremedio Date 2013-03-09 19:24
I don't use a real IDE, but I use SciTE: a text editor with some programming friendly features and sometimes I have the same problems, even if SciTE has an option for choosing the file encoding. But if I open the file in Notepad and Save As, selecting the correct encoding, the file now works perfectly in SciTE too. Have you tried this with Aptana?
Parent - By Nanaya Date 2013-03-09 21:08
It was Aptana, badly, but now I'm on EasyEclipse, who doesn't have the problem. I've had to add some plugin though.
Up Topic Gosu / Gosu Exchange / [Solved] Gosu and french

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill