]> granicus.if.org Git - php/commitdiff
Use zend_codepoint_to_uchar() macro.
authorAndrei Zmievski <andrei@php.net>
Wed, 25 Jan 2006 00:02:23 +0000 (00:02 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 25 Jan 2006 00:02:23 +0000 (00:02 +0000)
ext/standard/string.c

index 7102fbc67fc08e02778acfd7b4665b1837f36c8f..7194f804c105c3a42a3186563070a3b4265496fb 100644 (file)
@@ -2278,15 +2278,8 @@ PHP_FUNCTION(strpos)
                                php_error(E_WARNING, "Needle argument codepoint value out of range (0 - 0x10FFFF)");
                                RETURN_FALSE;
                        }
-                       /* supplementary codepoint values may require 2 UChar's */
-                       if (U_IS_BMP(Z_LVAL_PP(needle))) {
-                               u_needle_char[n_len++] = (UChar) Z_LVAL_PP(needle);
-                               u_needle_char[n_len]   = 0;
-                       } else {
-                               u_needle_char[n_len++] = (UChar) U16_LEAD(Z_LVAL_PP(needle));
-                               u_needle_char[n_len++] = (UChar) U16_TRAIL(Z_LVAL_PP(needle));
-                               u_needle_char[n_len]   = 0;
-                       }
+                       n_len += zend_codepoint_to_uchar(Z_LVAL_PP(needle), u_needle_char);
+                       u_needle_char[n_len] = 0;
 
                        /* locate the codepoint at the specified offset */
                        U16_FWD_N((UChar*)haystack, cp_offset, haystack_len, offset);