Skip to content

Commit 3bc01b5

Browse files
author
Moriyoshi Koizumi
committed
Modified mb_convert_case() to handle cased characters properly when MB_CASE_TITLE is specified.
1 parent 4a9f1a9 commit 3bc01b5

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ext/mbstring/php_unicode.c

+18-3
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,26 @@ PHPAPI char *php_unicode_convert_case(int case_mode, char *srcstr, size_t srclen
257257
}
258258
break;
259259

260-
case PHP_UNICODE_CASE_TITLE:
260+
case PHP_UNICODE_CASE_TITLE: {
261+
int mode = 0;
262+
261263
for (i = 0; i < unicode_len / sizeof(unsigned long); i++) {
262-
unicode_ptr[i] = php_unicode_totitle(unicode_ptr[i]);
264+
int res = php_unicode_is_prop(unicode_ptr[i],
265+
UC_MN|UC_ME|UC_CF|UC_LM|UC_SK|UC_LU|UC_LL|UC_LT, 0);
266+
if (mode) {
267+
if (res) {
268+
unicode_ptr[i] = php_unicode_tolower(unicode_ptr[i]);
269+
} else {
270+
mode = 0;
271+
}
272+
} else {
273+
if (res) {
274+
mode = 1;
275+
unicode_ptr[i] = php_unicode_totitle(unicode_ptr[i]);
276+
}
277+
}
263278
}
264-
break;
279+
} break;
265280

266281
}
267282

0 commit comments

Comments
 (0)