php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12647 sprintf, doubles and locale
Submitted: 2001-08-08 08:03 UTC Modified: 2002-06-16 09:13 UTC
From: artur at 2i dot pl Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: artur at 2i dot pl
New email:
PHP Version: OS:

 

 [2001-08-08 08:03 UTC] artur at 2i dot pl
sprintf ignores locale settings and always use . as the decimal separator.

Try this:

   setlocale("LC_NUMERIC", "pl_PL"); 
   echo sprintf("%.2f",doubleval("1,25"));

Result:
   1.25
(should be 1,25)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 09:13 UTC] hholzgra@php.net
fixed in CVS

and

  setlocale("LC_NUMERIC", "pl_PL"); 
  echo sprintf("%.2f",1.25);

will soon work (again?), too
no need to use the doubleval() workaround anymore


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 17 19:01:23 2020 UTC