php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #12337 Function fscanf does not correctly handle "\t" in format string
Submitted: 2001-07-24 09:45 UTC Modified: 2002-06-09 17:50 UTC
From: premysl dot dedic at conquest dot cz Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.4pl1 OS: Linux RedHat 6.2
Private report: No CVE-ID: None
 [2001-07-24 09:45 UTC] premysl dot dedic at conquest dot cz
When I copy&paste sample from documentation of fscanf function, I found, that it work incorrectly:

Sample:
while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {
    list ($name, $profession, $countrycode) = $userinfo;
}

Sample file:
abc<tab>def ghi jkl<tab> ..... <newline>
Note: <tab> means here a "tabelator" character (\t)

Result:
$name = 'abc'
$profession = 'def';
$contrycode = 'jkl';

I expect:
$name = 'abc'
$profession = 'def ghi jkl';
$contrycode = ' .... ';

What si wrong???


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-10 19:27 UTC] elixer@php.net
Whitespace characters (be they space, tab, or newline, etc.) in the format string matche one or more whitespace characters in the input.  So the second \t in your format string is matching the space between 'def' and 'ghi.'

The sample file from the documentation does not include "embedded whitespace" in the different data columns as yours does.

I'm changing this to a documentation problem because the (f)scanf documentation is really lacking.

Sean
 [2002-06-09 17:50 UTC] mfischer@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC