Skip to content

Commit 87a2373

Browse files
committed
- Fixed bug #52971 (PCRE-Meta-Characters not working with utf-8)
# In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII # characters, even in UTF-8 mode. However, this can be changed by setting # the PCRE_UCP option.
1 parent 00f75c7 commit 87a2373

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/pcre/php_pcre.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_le
350350
case 'S': do_study = 1; break;
351351
case 'U': coptions |= PCRE_UNGREEDY; break;
352352
case 'X': coptions |= PCRE_EXTRA; break;
353-
case 'u': coptions |= PCRE_UTF8; break;
353+
case 'u': coptions |= PCRE_UTF8;
354+
/* In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII
355+
characters, even in UTF-8 mode. However, this can be changed by setting
356+
the PCRE_UCP option. */
357+
#ifdef PCRE_UCP
358+
coptions |= PCRE_UCP;
359+
#endif
360+
break;
354361

355362
/* Custom preg options */
356363
case 'e': poptions |= PREG_REPLACE_EVAL; break;

0 commit comments

Comments
 (0)