<div dir="ltr">Is there an equivalent way of handling floats in text strings?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 19, 2015 at 1:38 PM, Willem Jan Palenstijn <span dir="ltr"><<a href="mailto:wjp@usecode.org" target="_blank">wjp@usecode.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Feb 19, 2015 at 01:14:59PM +0200, Filippos Karapetis wrote:<br>
> Well, it looks like sscanf() on Symbian isn't handling floating-point math<br>
> correctly (same as most floating point calculations in Symbian).<br>
><br>
> This StackOverflow question seems to verify this similar behavior with<br>
> atof() under Symbian:<br>
> <a href="http://stackoverflow.com/questions/11895686/atof-is-not-taking-entire-value-in-symbian" target="_blank">http://stackoverflow.com/questions/11895686/atof-is-not-taking-entire-value-in-symbian</a><br>
><br>
> If that is indeed the case, the only way to make this work is to roll our<br>
> own version of sscanf(), and handle floating-point math for Symbian in<br>
> there.<br>
<br>
<br>
<br>
Or just avoid the use of %f in sscanf in our engines.<br>
<br>
<br>
-Willem Jan<br>
<br>
<br>
<br>
> On Wed, Feb 18, 2015 at 8:43 PM, Федор <<a href="mailto:fedor_qd@mail.ru">fedor_qd@mail.ru</a>> wrote:<br>
><br>
> > Result is same.<br>
> ><br>
> ><br>
> > Fedor Strizhnev<br>
> > Федор Стрижнёв.<br>
> ><br>
> > Серада, 18 лютага 2015, 20:35 +02:00 ад Filippos Karapetis <<br>
> > <a href="mailto:bluegr@gmail.com">bluegr@gmail.com</a>>:<br>
> ><br>
> >   You're getting wrong results for sscanf(), which is why ZVision isn't<br>
> > working for you<br>
> ><br>
> > Try putting this line:<br>
> > setlocale(LC_ALL, "C");<br>
> > before your test code and try again<br>
> ><br>
> > On Wed, Feb 18, 2015 at 8:23 PM, Федор <<a href="mailto:fedor_qd@mail.ru">fedor_qd@mail.ru</a><br>
> > <<a href="https://e.mail.ru/compose/?mailto=mailto%3afedor_qd@mail.ru" target="_blank">https://e.mail.ru/compose/?mailto=mailto%3afedor_qd@mail.ru</a>>> wrote:<br>
> ><br>
> > I have:<br>
> > Test dot: 30.000000<br>
> > Test comma: 30.000000<br>
> ><br>
> > I confused.<br>
> ><br>
> > Fedor Strizhnev<br>
> > Федор Стрижнёв.<br>
> ><br>
> > Серада, 18 лютага 2015, 14:44 UTC ад Willem Jan Palenstijn <<br>
> > <a href="mailto:wjp@usecode.org">wjp@usecode.org</a><br>
> > <<a href="https://e.mail.ru/compose/?mailto=mailto%3awjp@usecode.org" target="_blank">https://e.mail.ru/compose/?mailto=mailto%3awjp@usecode.org</a>>>:<br>
> ><br>
> >   On Wed, Feb 18, 2015 at 02:42:08PM +0300, Fiodar Strizhniou wrote:<br>
> > > Is this test code good?<br>
> > ><br>
> > ><br>
> > > sscanf("30.981", "%f", &y)<br>
> > > printf("Test dot: \n")<br>
> > > print y;<br>
> > > sscanf("30,981", "%f", &y)<br>
> > > printf("Test comma: \n")<br>
> > > print y;<br>
> ><br>
> ><br>
> > I had a quick look at how ZVision uses sscanf, and something like that<br>
> > sounds<br>
> > good, yes.<br>
> ><br>
> > If you want something that actually compiles, try:<br>
> ><br>
> >         float y;<br>
> >         sscanf("30.981", "%f", &y);<br>
> >         printf("Test dot: %f\n", y);<br>
> >         sscanf("30,981", "%f", &y);<br>
> >         printf("Test comma: %f\n", y);<br>
> ><br>
> ><br>
> > You should get as output:<br>
> ><br>
> > Test dot: 30.981001<br>
> > Test comma: 30.000000<br>
> ><br>
> ><br>
> > -Willem Jan<br>
> ><br>
> ><br>
> > > исходное сбщ<br>
> > > Тема: Re: [Scummvm-devel] setlocale() doesn't work at Symbian<br>
> > > От: Федор <<a href="mailto:fedor_qd@mail.ru">fedor_qd@mail.ru</a><br>
> > <<a href="https://e.mail.ru/compose?To=fedor_qd@mail.ru" target="_blank">https://e.mail.ru/compose?To=fedor_qd@mail.ru</a>>><br>
> > > Дата: 17.02.2015 17.44<br>
> > ><br>
> > > I don't know what I need to test. Can you give me peace of code?<br>
> > ><br>
> > ><br>
> > > Fedor Strizhnev<br>
> > > Федор Стрижнёв.<br>
> > ><br>
> > > Аўторак, 17 лютага 2015, 13:47 UTC ад Willem Jan Palenstijn <<br>
> > <a href="mailto:wjp@usecode.org">wjp@usecode.org</a> <<a href="https://e.mail.ru/compose?To=wjp@usecode.org" target="_blank">https://e.mail.ru/compose?To=wjp@usecode.org</a>>>:<br>
> > > >On Tue, Feb 17, 2015 at 04:06:00PM +0300, Fiodar Strizhniou wrote:<br>
> > > >> I create bugreport month ago about bad colours in most scenes in<br>
> > Zvision engine games. I get point to wrong setlocale() settings in some<br>
> > backends. I create and run test app. Nothing works(see screenshot). Also i<br>
> > have read somewhere in Symbian Sdk docs what setlocale doesnt work at<br>
> > Symbian.<br>
> > > ><br>
> > > ><br>
> > > >You should really say things like that directly, instead of having us<br>
> > guess at<br>
> > > >what you're trying to do.<br>
> > > ><br>
> > > ><br>
> > > >The main question is: does sscanf work with "%f" for you? And if you<br>
> > set locale<br>
> > > >to "C" explicitly?<br>
> > > ><br>
> > > ><br>
> > > >-Willem Jan<br>
> > > ><br>
> > > ><br>
> > > ><br>
> > > >> исходное сбщ<br>
> > > >> Тема: Re: [Scummvm-devel] setlocale() doesn't work at Symbian<br>
> > > >> От: Filippos Karapetis < <a href="mailto:bluegr@gmail.com">bluegr@gmail.com</a><br>
> > <<a href="https://e.mail.ru/compose?To=bluegr@gmail.com" target="_blank">https://e.mail.ru/compose?To=bluegr@gmail.com</a>> ><br>
> > > >> Дата: 17.02.2015 14.52<br>
> > > >><br>
> > > >> You don't use a correct value for the locale<br>
> > > >><br>
> > > >> You would want something like:<br>
> > > >> setlocale(LC_ALL,"en_GB.ISO-8859-1");<br>
> > > >><br>
> > > >> Having said that, check backends/platform/sdl/sdl.cpp, where it does<br>
> > this:<br>
> > > >> const Common::String locale = setlocale(LC_ALL, "");<br>
> > > >><br>
> > > >> // Restore default C locale to prevent issues with<br>
> > > >> // portability of sscanf(), atof(), etc.<br>
> > > >> // See bug #3615148<br>
> > > >> setlocale(LC_ALL, "C");<br>
> > > >><br>
> > > >> Be careful when changing the locale, you need to reset it afterwards<br>
> > (as<br>
> > > >> the comment mentions).<br>
> > > >><br>
> > > >> This stackoverflow question may be helpful:<br>
> > > >><br>
> > <a href="http://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes" target="_blank">http://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes</a><br>
> > > >><br>
> > > >> On Tue, Feb 17, 2015 at 1:08 PM, Fiodar Strizhniou < <a href="mailto:fedor_qd@mail.ru">fedor_qd@mail.ru</a><br>
> > <<a href="https://e.mail.ru/compose?To=fedor_qd@mail.ru" target="_blank">https://e.mail.ru/compose?To=fedor_qd@mail.ru</a>> > wrote:<br>
> > > >><br>
> > > >> > I write simple application and run on phone:<br>
> > > >> > printf("Locale is: %s\n", setlocale(LC_ALL, "en_GB"));<br>
> > > >> > Locale is NULL<br>
> > > >> > Which parts (decimal separators, etc) should be set? Which values<br>
> > from<br>
> > > >> > setlocale() used?<br>
> > > >> > Always yours, Strizhniou Fedor.<br>
> > > >> > С уважением, Стрижнёв Фёдор.<br>
> > > >> ><br>
> > > >><br>
> > > >><br>
> > > >> --<br>
> > > >> "Experience is the name every one gives to their mistakes" - Oscar<br>
> > Wilde<br>
> > > ><br>
> > ><br>
> > ><br>
> > ><br>
> > ------------------------------------------------------------------------------<br>
> > > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server<br>
> > > from Actuate! Instantly Supercharge Your Business Reports and Dashboards<br>
> > > with Interactivity, Sharing, Native Excel Exports, App Integration & more<br>
> > > Get technology previously reserved for billion-dollar corporations, FREE<br>
> > ><br>
> > <a href="http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk" target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk</a><br>
> > > _______________________________________________<br>
> > > Scummvm-devel mailing list<br>
> > > <a href="mailto:Scummvm-devel@lists.sourceforge.net">Scummvm-devel@lists.sourceforge.net</a><br>
> > <<a href="https://e.mail.ru/compose?To=Scummvm%2ddevel@lists.sourceforge.net" target="_blank">https://e.mail.ru/compose?To=Scummvm%2ddevel@lists.sourceforge.net</a>><br>
> > > <a href="https://lists.sourceforge.net/lists/listinfo/scummvm-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/scummvm-devel</a><br>
> ><br>
> ><br>
> > ------------------------------------------------------------------------------<br>
> > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server<br>
> > from Actuate! Instantly Supercharge Your Business Reports and Dashboards<br>
> > with Interactivity, Sharing, Native Excel Exports, App Integration & more<br>
> > Get technology previously reserved for billion-dollar corporations, FREE<br>
> ><br>
> > <a href="http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk" target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk</a><br>
> > _______________________________________________<br>
> > Scummvm-devel mailing list<br>
> > <a href="mailto:Scummvm-devel@lists.sourceforge.net">Scummvm-devel@lists.sourceforge.net</a><br>
> > <<a href="https://e.mail.ru/compose?To=Scummvm%2ddevel@lists.sourceforge.net" target="_blank">https://e.mail.ru/compose?To=Scummvm%2ddevel@lists.sourceforge.net</a>><br>
> > <a href="https://lists.sourceforge.net/lists/listinfo/scummvm-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/scummvm-devel</a><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > "Experience is the name every one gives to their mistakes" - Oscar Wilde<br>
> ><br>
> ><br>
> ><br>
><br>
><br>
> --<br>
> "Experience is the name every one gives to their mistakes" - Oscar Wilde<br>
<br>
> ------------------------------------------------------------------------------<br>
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server<br>
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards<br>
> with Interactivity, Sharing, Native Excel Exports, App Integration & more<br>
> Get technology previously reserved for billion-dollar corporations, FREE<br>
> <a href="http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk" target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk</a><br>
<br>
> _______________________________________________<br>
> Scummvm-devel mailing list<br>
> <a href="mailto:Scummvm-devel@lists.sourceforge.net">Scummvm-devel@lists.sourceforge.net</a><br>
> <a href="https://lists.sourceforge.net/lists/listinfo/scummvm-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/scummvm-devel</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">"Experience is the name every one gives to their mistakes" - Oscar Wilde </div>
</div>