Req #39533 [Opn->Csd]: ord() cast with (unsigned char), chr() with (signed char)
| From: | pollita@php.net | Date: | Tue, 14 Mar 2017 23:56:28 +0000 |
| Subject: | Req #39533 [Opn->Csd]: ord() cast with (unsigned char), chr() with (signed char) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207841@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39533&edit=1
ID: 39533
Updated by: pollita@php.net
Reported by: fred at cashette dot com
Summary: ord() cast with (unsigned char), chr() with (signed
char)
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
Operating System: *
PHP Version: 5.2.0
-Assigned To:
+Assigned To: pollita
Block user comment: N
Private report: N
New Comment:
ord() needs to return an unsigned 8bit value (uchar) for BC reasons (and because it's just
consistent with \xHH and %HH notation as well as codepoint syntax.
chr() needs to cast to to char since PHP strings are c arrays of char.
Nothing to fix here.
Previous Comments:
------------------------------------------------------------------------
[2015-01-09 00:37:09] ajf@php.net
Wait, I think I misunderstood. You want chr() to cast to unsigned char? There might be a case for
that. Oops.
------------------------------------------------------------------------
[2015-01-09 00:35:55] ajf@php.net
Making ord() produce a signed char would make it inconsistent across platforms, as whether char is
signed or not varies. Plus, people are pretty used to it being unsigned.
------------------------------------------------------------------------
[2006-11-16 14:54:43] fred at cashette dot com
Description:
------------
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?revision=1.445.2.14.2.28&view=markup&sortby=date
PHP_FUNCTION(ord) ...
RETURN_LONG((unsigned char) Z_STRVAL_PP(str)[0]);
..
PHP_FUNCTION(chr) ...
temp[0] = (char) Z_LVAL_PP(num);
would not like use (unsigned char) in PHP_FUNCTION(chr) ? or opposite ?
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39533&edit=1