Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Wrong locale interpretation

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
alchemyx
Smarty Rookie


Joined: 19 Feb 2004
Posts: 8
Location: Swinoujscie, Poland

PostPosted: Fri Oct 01, 2004 7:04 pm    Post subject: Wrong locale interpretation Reply with quote

Hello!

In polish language comma is used to separate fractions from the rest. So we write 25,5 and it means twenty five and a half.

It is fine, when it is used when displaying data, but when doing internal things everything should be written using dot. So 25.5 not 25,5.

And now funny thing:
- on glibc 2.2.5 with full locale issuing 70*2.2 returns 140 and 70*"2,2" returns 154 (with locale set to pl_PL)
- on glibc 2.2.5 with removed polish locale 70*2.2 returns 154 as required
- on glibc 2.3.3 with full locale issuing 70*2.2 returns 154 as required.

So I am afraid it is Smarty bug, because doing those calculations under PHP does no harm with any locale set or unset. The bug also appears when you try to embed PHP code with {php} {/php}

Any ideas?
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Oct 01, 2004 7:27 pm    Post subject: Reply with quote

Hi alchemyx.

What are you trying to do with Smarty that isn't working? Do you have examples?

FYI: Smarty's in-template math does not observe locale settings as-far-as-I-know -- and I don't expect it to either.
Back to top
View user's profile Send private message
alchemyx
Smarty Rookie


Joined: 19 Feb 2004
Posts: 8
Location: Swinoujscie, Poland

PostPosted: Fri Oct 01, 2004 9:15 pm    Post subject: Reply with quote

Simple sample (what a name!):

{assign var=a value=70}
{assign var=b value=2.2}

{$a*$b}

Output shows: 140 instead of 154.

{assign var=a value=70}
{assign var=b value="2,2"}

{$a*$b}

Output shows 154.

It happens when I have setlocale(LC_ALL, "pl_PL"); in PHP.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Oct 02, 2004 7:14 am    Post subject: Reply with quote

this is (or better was) a php bug: http://bugs.php.net/bug.php?id=17079
Back to top
View user's profile Send private message Send e-mail Visit poster's website
alchemyx
Smarty Rookie


Joined: 19 Feb 2004
Posts: 8
Location: Swinoujscie, Poland

PostPosted: Sat Oct 02, 2004 8:39 am    Post subject: Reply with quote

It shows up in funny way Smile. But OK, if it is PHP problem can you tell me in which version it was fixed? According to that bug tracker it was fixed in 4.3.0 and found again.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Oct 02, 2004 9:53 am    Post subject: Reply with quote

dunno. i had the following phps at hand for testing

4.0.6 (buggy)
4.1.2 (buggy)
4.2.3 (buggy)
4.3.4 (ok)
4.3.5 (ok)
4.3.6 (ok)
4.3.7 (ok)
4.3.9 (ok)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
alchemyx
Smarty Rookie


Joined: 19 Feb 2004
Posts: 8
Location: Swinoujscie, Poland

PostPosted: Sat Oct 02, 2004 4:21 pm    Post subject: Reply with quote

OK. It is enough for me, I will make upgrade of PHP. Thanks!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP