#47489 [Opn]: Bad scan conversion character "F" (non-locale aware scanning not possible)
| From: | derick@php.net | Date: | Tue, 24 Feb 2009 10:18:54 +0000 |
| Subject: | #47489 [Opn]: Bad scan conversion character "F" (non-locale aware scanning not possible) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-134152@lists.php.net to get a copy of this message | ||
ID: 47489
Updated by: derick@php.net
Reported By: erwin dot derksen at zonnet dot nl
Status: Open
-Bug Type: Strings related
+Bug Type: Feature/Change Request
Operating System: Windows Vista
PHP Version: 5.2.8
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2009-02-24 10:09:04] 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)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47489&edit=1