|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-02-24 10:18 UTC] derick@php.net
[2011-04-08 20:37 UTC] jani@php.net
-Package: Feature/Change Request
+Package: Strings related
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
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)