From: Stefano Crocco Date: 2009-08-03T00:06:13+09:00 Subject: Re: qtruby overrides "to_s" depending on user's LOCALES On Sunday 02 August 2009, Iñaki Baz Castillo wrote: > |El Domingo, 2 de Agosto de 2009, Stefano Crocco escribió: > |> Regarding your question, you can find an explaination of why this > |> happens (and some workarounds) in this thread of the qtruby forum: > |> http://rubyforge.org/forum/message.php?msg_id=67059 > | > |Yes, after sending the mail I found the same thread :) > | > |> If you only want a quick solution, you can do the following: create a > |> Qt::Locale object based on the C locale using Qt::Locale.c, sets its > |> number_options property to Qt::Locale::OmitGroupSeparator and use its > |> to_string method to create the string. Something like this: > |> > |> x = 1234.567 > |> l = Qt::Locale.c > |> l.number_options = Qt::Locale::OmitGroupSeparator > |> puts l.to_string(x) > | > |But this is not valid to me since I use 3rd party libraries (as httpclient > |which suffers this issue when generating a HTTP request). You can try redefining the Float#to_s method after creating the application, using the code I suggested inside it. This works in a simple example, but I'm not sure what would happen in a real situation. require 'Qt4' a = Qt::Application.new [] class Float def to_s l = Qt::Locale.c l.number_options = Qt::Locale::OmitGroupSeparator l.to_string(self) end end x = 1234.567 puts x Stefano