php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42528 Out of "char"(8-bit) range value doesn't roll back, with uni-code ON.
Submitted: 2007-09-03 11:53 UTC Modified: 2009-08-25 15:56 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 6CVS-2007-09-03 (CVS) OS: RHEL4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
18 + 42 = ?
Subscribe to this entry?

 
 [2007-09-03 11:53 UTC] mahesh dot vemula at in dot ibm dot com
Description:
------------
The character(8-bit) range of value does not roll back to the corresponding minimum value, once the value reaches beyond the range of a char(8-bit) that it can hold, when Unicode is ON.


Reproduce code:
---------------
--TEST--
--FILE--
<?php
var_dump( decbin( ord(chr(255)) ) );
var_dump( decbin( ord(chr(256)) ) );
var_dump( decbin( ord(chr(257)) ) );
?>
--EXPECTF--


Expected result:
----------------
unicode(8) "11111111"
unicode(1) "0"
unicode(1) "1"

Actual result:
--------------
unicode(8) "11111111"
unicode(9) "100000000"
unicode(9) "100000001"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-07 12:30 UTC] mahesh dot vemula at in dot ibm dot com
Samething is happening for strncasecmp() function also.
 [2009-08-25 15:56 UTC] sjoerd@php.net
Thank you for your bug report.

In unicode, characters and bytes do not map one-on-one. That means that the codepoint for a character may be bigger than 256. The ord() function returns the numerical value for the codepoint, which may be bigger than 256. It should not wrap around as you describe.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 18:01:31 2024 UTC