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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Mar 19 06:01:30 2024 UTC