derick          Wed Sep 14 10:56:03 2005 EDT

  Modified files:              
    /php-src/ext/unicode        locale.c php_unicode.h unicode.c 
  Log:
  - Rename icu_loc* to i18n_loc*
  - Added i18n_strtotitle (name is not sure yet) - work in progress.
  
  
http://cvs.php.net/diff.php/php-src/ext/unicode/locale.c?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/unicode/locale.c
diff -u php-src/ext/unicode/locale.c:1.3 php-src/ext/unicode/locale.c:1.4
--- php-src/ext/unicode/locale.c:1.3    Thu Aug 18 08:56:36 2005
+++ php-src/ext/unicode/locale.c        Wed Sep 14 10:56:01 2005
@@ -14,11 +14,12 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: locale.c,v 1.3 2005/08/18 12:56:36 sniper Exp $ */ 
+/* $Id: locale.c,v 1.4 2005/09/14 14:56:01 derick Exp $ */ 
 
 #include "php_unicode.h"
 
 #if HAVE_UNICODE
+#include "unicode/ubrk.h"
 
 static void php_canonicalize_locale_id(char **target, int32_t *target_len, 
char *locale, UErrorCode *status)
 {
@@ -39,7 +40,7 @@
        *target_len = canonicalized_len;
 }
 
-PHP_FUNCTION(icu_loc_get_default)
+PHP_FUNCTION(i18n_loc_get_default)
 {
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
                return;
@@ -48,7 +49,7 @@
        RETURN_STRING(UG(default_locale), 1);
 }
 
-PHP_FUNCTION(icu_loc_set_default)
+PHP_FUNCTION(i18n_loc_set_default)
 {
        char *locale;
        int locale_len;
@@ -79,6 +80,67 @@
        RETURN_TRUE;
 }
 
+/* {{{ php_strtotitle
+ */
+PHPAPI char *php_strtotitle(char *s, size_t len)
+{
+       s[0] = toupper(s[0]);
+       return s;
+}
+/* }}} */
+
+/* {{{ php_u_strtotitle
+ */
+PHPAPI UChar* php_u_strtotitle(UChar **s, int32_t *len, const char* locale)
+{
+       UChar *dest = NULL;
+       int32_t dest_len;
+       UErrorCode status = U_ZERO_ERROR;
+       UBreakIterator *brkiter;
+       
+       dest_len = *len;
+       brkiter = ubrk_open(UBRK_TITLE, locale, *s, *len, &status);
+       while (1) {
+               status = U_ZERO_ERROR;
+               dest = eurealloc(dest, dest_len+1);
+               dest_len = u_strToTitle(dest, dest_len, *s, *len, NULL, locale, 
&status);
+               if (status != U_BUFFER_OVERFLOW_ERROR) {
+                       break;
+               }
+       }
+       ubrk_close(brkiter);
+
+       if (U_SUCCESS(status)) {
+               efree(*s);
+               dest[dest_len] = 0;
+               *s = dest;
+               *len = dest_len;
+       } else {
+               efree(dest);
+       }
+
+       return *s;
+}
+/* }}} */
+
+
+/* {{{ proto string strtoupper(string str)
+   Makes a string uppercase */
+PHP_FUNCTION(i18n_strtotitle)
+{
+       zval **arg;
+       
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg)) {
+               WRONG_PARAM_COUNT;
+       }
+       if (Z_TYPE_PP(arg) != IS_STRING && Z_TYPE_PP(arg) != IS_UNICODE) {
+               convert_to_text_ex(arg);
+       }
+
+       RETVAL_ZVAL(*arg, 1, 0);
+       php_u_strtotitle(&Z_USTRVAL_P(return_value), 
&Z_USTRLEN_P(return_value), UG(default_locale));
+}
+/* }}} */
 #endif /* HAVE_UNICODE */
 
 
http://cvs.php.net/diff.php/php-src/ext/unicode/php_unicode.h?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/unicode/php_unicode.h
diff -u php-src/ext/unicode/php_unicode.h:1.2 
php-src/ext/unicode/php_unicode.h:1.3
--- php-src/ext/unicode/php_unicode.h:1.2       Fri Aug 12 05:10:04 2005
+++ php-src/ext/unicode/php_unicode.h   Wed Sep 14 10:56:01 2005
@@ -14,7 +14,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_unicode.h,v 1.2 2005/08/12 09:10:04 sniper Exp $ */ 
+/* $Id: php_unicode.h,v 1.3 2005/09/14 14:56:01 derick Exp $ */ 
 
 #ifndef PHP_UNICODE_H
 #define PHP_UNICODE_H
@@ -55,8 +55,9 @@
 #include "TSRM.h"
 #endif
 
-PHP_FUNCTION(icu_loc_get_default);
-PHP_FUNCTION(icu_loc_set_default);
+PHP_FUNCTION(i18n_loc_get_default);
+PHP_FUNCTION(i18n_loc_set_default);
+PHP_FUNCTION(i18n_strtotitle);
 
 extern php_stream_filter_factory php_unicode_filter_factory;
 
http://cvs.php.net/diff.php/php-src/ext/unicode/unicode.c?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/unicode/unicode.c
diff -u php-src/ext/unicode/unicode.c:1.4 php-src/ext/unicode/unicode.c:1.5
--- php-src/ext/unicode/unicode.c:1.4   Sat Aug 13 22:03:02 2005
+++ php-src/ext/unicode/unicode.c       Wed Sep 14 10:56:01 2005
@@ -15,7 +15,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: unicode.c,v 1.4 2005/08/14 02:03:02 sniper Exp $ */ 
+/* $Id: unicode.c,v 1.5 2005/09/14 14:56:01 derick Exp $ */ 
 
 #include "php_unicode.h"
 #if HAVE_UNICODE
@@ -102,10 +102,11 @@
 }
 /* {{{ unicode_functions[] */
 function_entry unicode_functions[] = {
-       PHP_FE(icu_loc_get_default, NULL)
-       PHP_FE(icu_loc_set_default, NULL)
+       PHP_FE(i18n_loc_get_default, NULL)
+       PHP_FE(i18n_loc_set_default, NULL)
        PHP_FE(unicode_decode, NULL)
        PHP_FE(unicode_encode, NULL)
+       PHP_FE(i18n_strtotitle, NULL)
        { NULL, NULL, NULL }
 };
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to