Hi, Here is small test program: ---------------- require ''rubygems'' require ''fox16'' puts Time.now $app = Fox::FXApp.new puts Time.now ---------------- Here is what it gives on my computer: ---------------- Tue Dec 04 08:40:14 +0100 2007 mar. d?c. 04 08:40:14 +0100 2007 ---------------- After FXApp is instanciated, the Time class is suddenly being localized, and this breaks a few things elsewhere is my program. I''m a french speaker, and second line means that the week day is "mardi", and month is "d?cembre". Unfortunately, "?" is not printed correctly in my windows console. You get this "?" instead. Can anyone tell me me what happens here? Is there a workaround? Philippe
Philippe Lang wrote:> Hi, > > Here is small test program: > > ---------------- > require ''rubygems'' > require ''fox16'' > > puts Time.now > > $app = Fox::FXApp.new > > puts Time.now > ---------------- > > Here is what it gives on my computer: > > ---------------- > Tue Dec 04 08:40:14 +0100 2007 > mar. d?c. 04 08:40:14 +0100 2007 > ---------------- > > After FXApp is instanciated, the Time class is suddenly being > localized, and this breaks a few things elsewhere in my program. > > I''m a french speaker, and second line means that the week day is > "mardi", and month is "d?cembre". Unfortunately, "?" is not printed > correctly in my windows console. You get this "?" instead. > > Can anyone tell me me what happens here? Is there a workaround?I have found a workaround with class DateTime, instead of Time: ---------------- require ''rubygems'' require ''fox16'' puts DateTime.now $app = Fox::FXApp.new puts DateTime.now ---------------- This gives: ---------------- 2007-12-04T09:23:35+01:00 2007-12-04T09:23:35+01:00 ---------------- ... which looks better! Philippe
On 12/4/07, Philippe Lang <philippe.lang at attiksystem.ch> wrote:> After FXApp is instanciated, the Time class is suddenly being localized, > and this breaks a few things elsewhere is my program. > > Can anyone tell me me what happens here? Is there a workaround?You are correct that when the FXApp instance is initialized, it calls the setlocale() function (from the C library) to set the locale to the native environment (presumably, "fr-FR" in your case). Then Ruby''s Time class uses the strftime() function from the C library to provide the stringified version of the time, and strftime() uses the current locale in that process. So that''s why you''re getting localized day and month names. I know that you''ve already found a workaround, using the DateTime class instead of the Time class, but I *think* another workaround would be to set the LC_ALL environment variable to "en_US" (or some other English-language locale). Then, when FOX calls setlocale(), it would pick up this value instead of the default "fr_FR" value that it''s currently getting. Hope this helps, Lyle