Bug #70591 [Opn->Nab]: ord() no longer yields correct results consistently
Edit report at https://bugs.php.net/bug.php?id=70591&edit=1
ID: 70591
Updated by: requinix@php.net
Reported by: slevy1 at pipeline dot com
Summary: ord() no longer yields correct results consistently
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: n/a
PHP Version: 7.0.0RC3
Block user comment: N
Private report: N
New Comment:
The default character encoding, which your calls to mb_strcut() will be using, changed to be UTF-8
in PHP 5.6.
https://3v4l.org/YE6I9
Previous Comments:
------------------------------------------------------------------------
[2015-09-27 00:10:39] slevy1 at pipeline dot com
Description:
------------
I used ord() in combination with mb_strcut() to obtain the byte values of a multibyte char utf-8
encoded. This used to work in PHP 5.4.8 - 5.5.29. But in PHP5.6-PHP7.00rc3 it doesn't work
any more :(
Test script:
---------------
<?php
$str = "â¥"; // 3 byte values per above
var_dump( ord(mb_strcut($str, 0, 1) ));
var_dump( ord(mb_strcut($str, 1, 1) ));
var_dump( ord(mb_strcut($str, 2, 1) ));
see live code: https://3v4l.org/OoFus
Expected result:
----------------
I expected the var dumps to produce decimal results as follows:
226
153
165
Actual result:
--------------
0
0
0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70591&edit=1
Thread (5 messages)