rfc:grapheme_strrev

PHP RFC: grapheme_strrev: strrev for grapheme cluster

Introduction

This proposal is strrev for grapheme cluster unit function. User land sometimes shows mb_strrev function, but mbstring(Unicode code point unit) can not support multi code point (for example, emoji etc...).

Almost same of Swift's String.reversed().

Proposal

Add grapheme_strrev function.

<?php
 
echo grapheme_strrev("αあいうえお👨‍👨‍👧‍👦"); // result is "👨‍👨‍👧‍👦おえういあα"
 
?>

Backward Incompatible Changes

This could break a function existing in userland with the same name.

Proposed PHP Version(s)

Next of PHP 8.5 (PHP 8.6 or PHP 9.0)

RFC Impact

To the Ecosystem

What effect will the RFC have on IDEs, Language Servers (LSPs), Static Analyzers, Auto-Formatters, Linters and commonly used userland PHP libraries?

To Existing Extensions

Will existing extensions be affected?

To SAPIs

Describe the impact to CLI, Development web server, embedded PHP etc.

Open Issues

Make sure there are no open issues when the vote starts!

Future Scope

This section should outline areas that you are not planning to work on in the scope of this RFC, but that might be iterated upon in the future by yourself or another contributor.

This helps with long-term planning and ensuring this RFC does not prevent future work.

Voting Choices

Pick a title that reflects the concrete choice people will vote on.

Please consult the php/policies repository for the current voting guidelines.


Primary Vote requiring a 2/3 majority to accept the RFC:

Add grapheme_strrev function
Real name Yes No Abstain
Final result: 0 0 0
This poll has been closed.

Patches and Tests

Links to proof of concept PR.

If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed.

Implementation

After the RFC is implemented, this section should contain:

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature

References

Links to external references, discussions, or RFCs.

Rejected Features

Keep this updated with features that were discussed on the mail lists.

Changelog

If there are major changes to the initial proposal, please include a short summary with a date or a link to the mailing list announcement here, as not everyone has access to the wikis' version history.

rfc/grapheme_strrev.txt · Last modified: by youkidearitai