Req #69512 [Com]: No multibyte strrev function

From: Date: Wed, 28 Dec 2022 10:11:09 +0000
Subject: Req #69512 [Com]: No multibyte strrev function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243261@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69512&edit=1

 ID:                 69512
 Comment by:         amin dot jabari242 at gmail dot com
 Reported by:        550794054 at qq dot com
 Summary:            No multibyte strrev function
 Status:             Open
 Type:               Feature/Change Request
 Package:            mbstring related
 Operating System:   windows
 PHP Version:        5.6.8
 Block user comment: N
 Private report:     N

 New Comment:

The solution worked for me ok  to the community and the members for the solution.
(https://www.myjdfaccount.us/)github.com


Previous Comments:
------------------------------------------------------------------------
[2019-02-01 00:42:47] sound1st dot piano at gmail dot com

PHP must implement a function like:

mb_strrev ( string $string [, string $encoding = mb_internal_encoding() ] ) : string


It is out of the question that a programming language cannot support multibyte encodings fully in
this day and age.

Stackoverflow:
https://stackoverflow.com/questions/17496493/strrev-dosent-support-utf-8

------------------------------------------------------------------------
[2015-04-23 15:36:19] 550794054 at qq dot com

Thanks for reply me.I'm a begin PHP learner.I also konw it's can use the regular
expression can deal with the problem.But it's so hard.I think if there can be an instruction
can use,it will be better.Because there come to
"mb_subtr()","mb_strpos()","mb_strstr()",why just add
"mb_strrev"?
it's just my advice,thanks again for reply me.

------------------------------------------------------------------------
[2015-04-23 13:20:11] cmb@php.net

A mb_strrev would not necessarily give the desired results, because
the mb_* functions work on code points (when dealing with UTF-8),
what doesn't cater to combining chars. A grapheme_strrev would be
more useful.

------------------------------------------------------------------------
[2015-04-23 13:14:14] requinix@php.net

strrev(), like most other string functions, operate on bytes. They are not suitable for multibyte
strings.

There is no "mb_strrev" function so I'm turning this ticket into a feature request
for one.
Meanwhile the best option *for UTF-8 strings* I can think of is to use preg_split() or _match() with
/u to split the input into characters, reverse the array, and implode() them back together.

------------------------------------------------------------------------
[2015-04-23 13:02:47] 550794054 at qq dot com

Description:
------------
---
From manual page: http://www.php.net/function.strrev
---
I find the instruction "strrev" cannot support non-English string,if want to reverse like
chinese string ,Janpanese string,or Russian string,"strrev" will display gibberish.even
add Prefix "mb_" also not support.

Test script:
---------------
<?php
$str="我的名字叫小明”;
$str1=strrev($str);
echo $str1;
?>

Expected result:
----------------
maybe it's the problem belongs to C.but I also want to PHP group can fix the problem. Thank
you! 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69512&edit=1


Thread (1 message)

  • amin dot jabari242 at gmail dot com
  • Unknown Message
    • amin dot jabari242 at gmail dot com
« previous php.bugs (#243261) next »