rrichards Wed Sep 8 06:16:58 2004 EDT Modified files: (Branch: PHP_5_0) /php-src/ext/libxml libxml.c php_libxml.h Log: MFH: implement php_libxml_xmlCheckUTF8 - workaround for <= libxml2-2.6.13 function http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.18.2.3&r2=1.18.2.4&ty=u Index: php-src/ext/libxml/libxml.c diff -u php-src/ext/libxml/libxml.c:1.18.2.3 php-src/ext/libxml/libxml.c:1.18.2.4 --- php-src/ext/libxml/libxml.c:1.18.2.3 Mon Sep 6 06:18:29 2004 +++ php-src/ext/libxml/libxml.c Wed Sep 8 06:16:57 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libxml.c,v 1.18.2.3 2004/09/06 10:18:29 rrichards Exp $ */ +/* $Id: libxml.c,v 1.18.2.4 2004/09/08 10:16:57 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.8.2.1&r2=1.8.2.2&ty=u Index: php-src/ext/libxml/php_libxml.h diff -u php-src/ext/libxml/php_libxml.h:1.8.2.1 php-src/ext/libxml/php_libxml.h:1.8.2.2 --- php-src/ext/libxml/php_libxml.h:1.8.2.1 Thu Aug 5 17:03:15 2004 +++ php-src/ext/libxml/php_libxml.h Wed Sep 8 06:16:57 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_libxml.h,v 1.8.2.1 2004/08/05 21:03:15 edink Exp $ */ +/* $Id: php_libxml.h,v 1.8.2.2 2004/09/08 10:16:57 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