rrichards               Wed Sep  8 06:15:42 2004 EDT

  Modified files:              
    /php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  implement php_libxml_xmlCheckUTF8
   - workaround for pre libxml2-2.6.13 function
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.22&r2=1.23&ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.22 php-src/ext/libxml/libxml.c:1.23
--- php-src/ext/libxml/libxml.c:1.22    Mon Sep  6 06:16:34 2004
+++ php-src/ext/libxml/libxml.c Wed Sep  8 06:15:41 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: libxml.c,v 1.22 2004/09/06 10:16:34 rrichards Exp $ */
+/* $Id: libxml.c,v 1.23 2004/09/08 10:15:41 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -505,6 +505,32 @@
 
 
 /* {{{ Common functions shared by extensions */
+int php_libxml_xmlCheckUTF8(const unsigned char *s)
+{
+       int i;
+       unsigned char c;
+
+       for (i = 0; (c = s[i++]);) {
+               if ((c & 0x80) == 0) {
+               } else if ((c & 0xe0) == 0xc0) {
+                       if ((s[i++] & 0xc0) != 0x80) {
+                               return 0;
+                       }
+               } else if ((c & 0xf0) == 0xe0) {
+                       if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
+                               return 0;
+                       }
+               } else if ((c & 0xf8) == 0xf0) {
+                       if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || 
(s[i++] & 0xc0) != 0x80) {
+                               return 0;
+                       }
+               } else {
+                       return 0;
+               }
+       }
+       return 1;
+}
+
 int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node 
export_function)
 {
        php_libxml_func_handler export_hnd;
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.9 php-src/ext/libxml/php_libxml.h:1.10
--- php-src/ext/libxml/php_libxml.h:1.9 Sun Jul 25 08:00:28 2004
+++ php-src/ext/libxml/php_libxml.h     Wed Sep  8 06:15:41 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_libxml.h,v 1.9 2004/07/25 12:00:28 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.10 2004/09/08 10:15:41 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -80,6 +80,7 @@
 PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
 void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
 void php_libxml_ctx_error(void *ctx, const char *msg, ...);
+PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
 
 #endif /* HAVE_LIBXML */
 

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

Reply via email to