php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46385 sscanf does not work with %b
Submitted: 2008-10-25 14:22 UTC Modified: 2012-08-28 03:37 UTC
From: delilahblue at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.6 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2008-10-25 14:22 UTC] delilahblue at gmail dot com
Description:
------------
sscanf does not work with %b in the format string.
PHP 5.2.6-pl7-gentoo (cli) (built: Sep 27 2008 23:46:17)
Linux version 2.6.24-tuxonice-r9 (gcc version 4.1.2 (Gentoo 4.1.2)) #1 SMP PREEMPT Fri Oct 3 11:58:28 CEST 2008

USE-flags: apache2 bcmath berkdb bzip2 cli crypt ctype curl gd gdbm hash iconv ipv6 mysql mysqli ncurses nls pcre readline reflection session sockets spell spl ssl truetype unicode xml zlib

other people on freenode#php have the same issue
for example with php-5.2.4-2ubuntu5.3 on
Linux dev 2.6.24-19-386 #1 Wed Aug 20 21:59:50 UTC 2008 i686 GNU/Linux

Reproduce code:
---------------
echo sscanf("01010101", "%b");

Expected result:
----------------
It should output "85".

Actual result:
--------------
Warning: sscanf(): Bad scan conversion character "b" in php shell code on line 1
Call Stack:
 3740.1460     179568   1. {main}() php shell code:0
 3740.1460     179568   2. sscanf() php shell code:1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-26 11:09 UTC] jani@php.net
See bug #46267
 [2012-08-28 03:37 UTC] datibbaw@php.net
This should be updated in the documentation, right now there's no mention about 
'%b'.
 [2012-08-28 06:07 UTC] mail at bodograumann dot de
It seems that http://php.net/sscanf solves the documentation problem by saying

The interpreted format for str, which is described in the documentation for sprintf() with following differences:
    F, g, G and b are not supported.

So this bug can be closed. Although a new one might be opened as a feature request, if the "%b" is needed.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jan 25 23:01:24 2020 UTC