php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47489 Bad scan conversion character "F" (non-locale aware scanning not possible)
Submitted: 2009-02-24 10:09 UTC Modified: 2011-04-08 20:37 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: erwin dot derksen at zonnet dot nl Assigned:
Status: Open Package: Strings related
PHP Version: 5.2.8 OS: Windows Vista
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: erwin dot derksen at zonnet dot nl
New email:
PHP Version: OS:

 

 [2009-02-24 10:09 UTC] erwin dot derksen at zonnet dot nl
Description:
------------
According to the documentation the format string is interpreted as described in the documentation for sprintf. However, function testSscanf() issues a warning 'Bad scan conversion character "F"'.

On further examination, it is not just a documentation error but an error in sscanf, see function testSscanf2()

Note that the dutch locale (nld) formats the decimal point as comma (,) and the thousand separator as a point (.).

Reproduce code:
---------------
function testSscanf()
{
	$f = null;
	$s = sprintf("%F", 1.34);
	$r = sscanf($s, "%F", $f);
	echo $f;
}

function testSscanf2()
{
	setlocale(LC_ALL, "nld");
	$f = 1.34;
	$s1 = sprintf("%f", $f);
	$s2 = sprintf("%F", $f);
	sscanf($s1, "%f", $f1);
	sscanf($s2, "%f", $f2);
	sscanf($s1, "%F", $f3);
	sscanf($s2, "%F", $f4);
	echo 's1 = ' . $s1 . "<br/>\n";
	echo 's2 = ' . $s2 . "<br/>\n";
	echo 'f = ' . $f . "<br/>\n";
	echo 'f1 = ' . $f1 . " (%f scanned from %f printed)<br/>\n";
	echo 'f2 = ' . $f2 . " (%f scanned from %F printed)<br/>\n";
	echo 'f3 = ' . $f3 . " (%F scanned from %f printed)<br/>\n";
	echo 'f4 = ' . $f4 . " (%F scanned from %F printed)<br/>\n";
}


Expected result:
----------------
1,34
1
1
1.34

Actual result:
--------------
s1 = 1,340000
s2 = 1.340000
f = 1,34
f1 = 1 (%f scanned from %f printed)
f2 = 1,34 (%f scanned from %F printed)
f3 = (%F scanned from %f printed)
f4 = (%F scanned from %F printed)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-24 10:18 UTC] derick@php.net
I think this is just not implemented for scanning... as we use the standard libc functions for this. I'm marking this as a feature request.
 [2011-04-08 20:37 UTC] jani@php.net
-Package: Feature/Change Request +Package: Strings related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 09:01:24 2019 UTC