php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46634 Array key differentiates between unicode and binary strings
Submitted: 2008-11-20 19:04 UTC Modified: 2009-01-03 01:19 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mike at mikegerwitz dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 6CVS-2008-11-20 (snap) OS: GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mike at mikegerwitz dot com
New email:
PHP Version: OS:

 

 [2008-11-20 19:04 UTC] mike at mikegerwitz dot com
Description:
------------
Array keys in PHP 6 differentiate between unicode and binary strings - that is, a unicode key of 'test' is entirely different than a binary key of 'test'.

Reproduce code:
---------------
$arr = array();
$arr[ (unicode)'test' ] = 'unicode';
$arr[ (binary)'test' ] = 'binary';

// If unicode semantics is enabled, this will output 'unicode'
var_dump( $arr['test'] );

// Will output 'binary'
var_dump( $arr[ b'test'] );

// Will output 'unicode'
var_dump( $arr[ (unicode)'test' ] );

Expected result:
----------------
All three lines should output 'binary'

unicode(7) "binary"
unicode(6) "binary"
unicode(7) "binary"

Actual result:
--------------
unicode(7) "unicode"
unicode(6) "binary"
unicode(7) "unicode"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-03 01:19 UTC] felipe@php.net
Nowadays unicode semantics is always enabled.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC