cvs: php-src /ext/unicode property.c
| From: | Andrei Zmievski | Date: | Thu, 04 May 2006 21:22:30 +0000 |
| Subject: | cvs: php-src /ext/unicode property.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-38027@lists.php.net to get a copy of this message | ||
andrei Thu May 4 21:22:30 2006 UTC
Modified files:
/php-src/ext/unicode property.c
Log:
Implement char_from_name().
http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/property.c?r1=1.7&r2=1.8&diff_format=u
Index: php-src/ext/unicode/property.c
diff -u php-src/ext/unicode/property.c:1.7 php-src/ext/unicode/property.c:1.8
--- php-src/ext/unicode/property.c:1.7 Thu May 4 18:37:12 2006
+++ php-src/ext/unicode/property.c Thu May 4 21:22:30 2006
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: property.c,v 1.7 2006/05/04 18:37:12 andrei Exp $ */
+/* $Id: property.c,v 1.8 2006/05/04 21:22:30 andrei Exp $ */
#include "php_unicode.h"
@@ -369,6 +369,35 @@
PHP_FUNCTION(char_from_name)
{
+ UChar *name;
+ int name_len;
+ UChar32 ch;
+ UCharNameChoice choice = U_UNICODE_CHAR_NAME;
+ zend_bool extended = FALSE;
+ char *buf;
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u|b", &name, &name_len,
&extended) == FAILURE) {
+ return;
+ }
+
+ if (extended) {
+ choice = U_EXTENDED_CHAR_NAME;
+ }
+
+ buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC);
+ if (buf) {
+ ch = u_charFromName(choice, buf, &status);
+ if (U_SUCCESS(status)) {
+ RETVAL_UCHAR32(ch);
+ } else {
+ RETVAL_FALSE;
+ }
+ } else {
+ php_error(E_WARNING, "Character name has to consist only of ASCII characters");
+ RETURN_FALSE;
+ }
+ efree(buf);
}
PHP_FUNCTION(char_get_name)