strrev() impl - Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/standard string.c
| From: | Rolland Santimano | Date: | Mon, 22 Aug 2005 10:48:41 +0000 |
| Subject: | strrev() impl - Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/standard string.c | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-18241@lists.php.net to get a copy of this message | ||
--- Andrei Zmievski <andrei@gravitonic.com> wrote:
> 2) Combining sequences are not respected. We can't swap base
> character and the combining chars that follow it because the string
> may be concatenated with something else and the combining chars may
> end up affecting something else. So we need to work at grapheme level
> here, using u_getCombiningClass() to check for combining chars and
> copying the base+combining as a unit.
OK, so I guess the code should track the combining class and copy out
chunks of codepoints with the same class, something like:
int32_t prev; /* Last class transition */
uint8_t class = 0;
while ( /* iterate backward over string */ ) {
while (u_getCombiningClass(codept) == class) {
/* Get 'next' codept */
}
/* Copy codepts from 'next' to 'prev' */
}
Is that correct ?
--
Rolland