php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61578 bin2hex() definition is ambiguous
Submitted: 2012-03-31 02:25 UTC Modified: 2012-04-04 09:50 UTC
Votes:2
Avg. Score:1.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: unsure at tactileint dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: any
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: unsure at tactileint dot com
New email:
PHP Version: OS:

 

 [2012-03-31 02:25 UTC] unsure at tactileint dot com
Description:
------------
---
From manual page: http://www.php.net/function.bin2hex#refsect1-function.bin2hex-description
---

"Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first. "

ambiguous.  Which you mean?

'01101000' => '68'   first nibble, 6, is higher order, 0110
or
'0110' => '30313130'  first nibble, 3, is higher order in char '0' = 30

In both cases the input string is 'binary'.  Given that '123ABC' is considered headecimal, doesn't it follow that '01101000' is binary?

Including a few unambiguous examples would solve the problem.  Like:
bin2hex('or') => '6f72'



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-02 11:41 UTC] phpmpan at mpan dot pl
I see no ambiguity in the description.

According to function description your first interpretation is wrong. It is clearly stated that `bin2hex` converts binary data, not a textual representation of a number in 2-based positional numeral system:

"bin2hex — Convert binary data into hexadecimal representation"
 [2012-04-04 09:50 UTC] bjori@php.net
-Status: Open +Status: Not a bug
 [2012-04-04 09:50 UTC] bjori@php.net
See phpmpan comment
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 20:01:32 2024 UTC