Re: strrev() impl - Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/standard string.c

From: Date: Mon, 22 Aug 2005 17:12:18 +0000
Subject: Re: 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-18261@lists.php.net to get a copy of this message
Not quite. The base characters have a combining class of 0, while for the combining ones that value is > 0 but not necessarily the same. For example: a +ˉ + ˳ (0 + 230 + 220) So the code needs to capture sequences starting with class of 0 and followed by one or more chars with class > 0: int32_t prev; /* Last class transition */ uint8_t class = 0; while ( /* iterate backward over string */ ) {
    while (u_getCombiningClass(codept) > 0) {
       	/* Get 'next' codept */
    }
    /* Copy codepts from 'next' to 'prev' */
    prev = current point of iteration;
} -Andrei On Aug 22, 2005, at 3:48 AM, Rolland Santimano wrote:
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


« previous php.internals (#18261) next »