andrei Mon Aug 14 21:04:50 2006 UTC
Modified files:
/php-src unicode-progress.txt
/php-src/ext/standard string.c
Log:
Unicode support for str_split().
http://cvs.php.net/viewvc.cgi/php-src/unicode-progress.txt?r1=1.42&r2=1.43&diff_format=u
Index: php-src/unicode-progress.txt
diff -u php-src/unicode-progress.txt:1.42 php-src/unicode-progress.txt:1.43
--- php-src/unicode-progress.txt:1.42 Mon Aug 14 20:43:23 2006
+++ php-src/unicode-progress.txt Mon Aug 14 21:04:50 2006
@@ -49,9 +49,6 @@
Params API, IS_UNICODE upgrade. Case-folding should be handled
similar to stristr().
- str_split()
- IS_UNICODE support, split on codepoint level.
-
str_word_count()
Params API, IS_UNICODE support, using u_isalpha(), etc.
@@ -190,6 +187,7 @@
str_repeat()
str_rot13()
str_shuffle()
+ str_split()
strcspn()
strip_tags()
stripcslashes()
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.577&r2=1.578&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.577 php-src/ext/standard/string.c:1.578
--- php-src/ext/standard/string.c:1.577 Mon Aug 14 20:43:23 2006
+++ php-src/ext/standard/string.c Mon Aug 14 21:04:50 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.577 2006/08/14 20:43:23 andrei Exp $ */
+/* $Id: string.c,v 1.578 2006/08/14 21:04:50 andrei Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -6973,17 +6973,19 @@
/* }}} */
#endif
-/* {{{ proto array str_split(string str [, int split_length])
+/* {{{ proto array str_split(string str [, int split_length]) U
Convert a string to an array. If split_length is specified, break the
string down into chunks each split_length characters long. */
PHP_FUNCTION(str_split)
{
- char *str;
+ zstr str;
int str_len;
long split_length = 1;
char *p;
+ zend_uchar str_type;
int n_reg_segments;
+ int charsize = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str,
&str_len, &split_length) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|l", &str,
&str_len, &str_type, &split_length) == FAILURE) {
return;
}
@@ -6995,20 +6997,23 @@
array_init(return_value);
if (split_length >= str_len) {
- add_next_index_stringl(return_value, str, str_len, 1);
+ add_next_index_zstrl(return_value, str, str_len, str_type, 1);
return;
}
n_reg_segments = floor(str_len / split_length);
- p = str;
+ p = str.s;
+ if (str_type == IS_UNICODE) {
+ charsize = 2;
+ }
while (n_reg_segments-- > 0) {
- add_next_index_stringl(return_value, p, split_length, 1);
- p += split_length;
+ add_next_index_zstrl(return_value, ZSTR(p), split_length,
str_type, 1);
+ p += split_length * charsize;
}
- if (p != (str + str_len)) {
- add_next_index_stringl(return_value, p, (str + str_len - p), 1);
+ if (p != (str.s + str_len * charsize)) {
+ add_next_index_zstrl(return_value, ZSTR(p), (str.s + str_len *
charsize - p), str_type, 1);
}
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php