php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72831 Add encoding option for chr and ord
Submitted: 2016-08-14 03:52 UTC Modified: 2017-01-09 05:35 UTC
From: masakielastic at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: Strings related
PHP Version: Next Minor Version OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: masakielastic at gmail dot com
New email:
PHP Version: OS:

 

 [2016-08-14 03:52 UTC] masakielastic at gmail dot com
Description:
------------
This proposal is about adding the encoding option for chr and ord.

string chr ( int $codepoint [, string $encoding = "ISO-8859-1"] )
int ord ( string $string [, string $encoding = "ISO-8859-1"] )

The conversion between character and codepoint can be widely seen in learning Unicode spec, escaping dangerous characters for security, replacing emoji with image for legacy smartphone.

Although intl and mbstring module have the conversion feature (IntlChar::chr, IntlChar::ord, mb_chr, mb_ord), A lot of people are satisfied with UTF-8 and the developers of frameworks want to reduce the dependencies of modules. Symfony developers maintain intl and polyfill-mbstring component.


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-14 04:18 UTC] requinix@php.net
-Summary: The encoding option for chr and ord +Summary: Add encoding option for chr and ord
 [2016-08-14 04:18 UTC] requinix@php.net
Since this involves character encoding I suggest you mention it on the internals mailing list. http://php.net/mailing-lists.php Not that I would expect it to require an RFC, but (a) mbstring's age factors into this and (b) such changes could be useful for IntlChar too. There's room for discussion about the issue as a whole, not just the modifications to chr and ord.

One thing to mention now: the default should be according to the default_charset setting (http://php.net/manual/en/ini.core.php#ini.default-charset) as is done with a few other functions.
 [2017-01-09 05:35 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2017-01-09 05:35 UTC] krakjoe@php.net
Since this requires an RFC, and there is a PR open on github, closing this issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC