cvs: /php4/ext/wddx wddx.c
| From: | Thies C. Arntzen | Date: | Tue, 04 Apr 2000 15:47:42 +0000 |
| Subject: | cvs: /php4/ext/wddx wddx.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13097@lists.php.net to get a copy of this message | ||
thies Tue Apr 4 08:47:42 2000 EDT
Modified files:
/php4/ext/wddx wddx.c
Log:
@- WDDX now defaults to ISO-8859-1. (Thies)
# andrei, plz have a look at my changes - seems to work for me!
Index: php4/ext/wddx/wddx.c
diff -u php4/ext/wddx/wddx.c:1.30 php4/ext/wddx/wddx.c:1.31
--- php4/ext/wddx/wddx.c:1.30 Tue Apr 4 04:35:01 2000
+++ php4/ext/wddx/wddx.c Tue Apr 4 08:47:11 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.30 2000/04/04 11:35:01 thies Exp $ */
+/* $Id: wddx.c,v 1.31 2000/04/04 15:47:11 thies Exp $ */
#include "php.h"
#include "php_wddx.h"
@@ -35,6 +35,8 @@
#if HAVE_WDDX
#include "php_wddx_api.h"
+#define PHP_XML_INTERNAL
+#include "ext/xml/php_xml.h"
#define WDDX_BUF_LEN 256
#define PHP_CLASS_NAME_VAR "php_class_name"
@@ -579,7 +581,10 @@
for (i=0; atts[i]; i++) {
if (!strcmp(atts[i], EL_VAR_NAME) && atts[i+1]) {
- stack->varname = estrdup(atts[i+1]);
+ char *decoded_value;
+ int decoded_len;
+ decoded_value =
xml_utf8_decode(atts[i+1],strlen(atts[i+1]),&decoded_len,"ISO-8859-1");
+ stack->varname = decoded_value;
}
}
}
@@ -667,21 +672,27 @@
{
st_entry *ent;
wddx_stack *stack = (wddx_stack *)user_data;
+ char *decoded_value;
+ int decoded_len;
if (!wddx_stack_is_empty(stack)) {
wddx_stack_top(stack, (void**)&ent);
switch (ent->type) {
- case ST_STRING:
+ case ST_STRING:
+ decoded_value = xml_utf8_decode(s,len,&decoded_len,"ISO-8859-1");
+
if (ent->data->value.str.len == 0) {
- ent->data->value.str.val = estrndup(s, len);
- ent->data->value.str.len = len;
+ ent->data->value.str.val = estrndup(decoded_value, decoded_len);
+ ent->data->value.str.len = decoded_len;
} else {
ent->data->value.str.val = erealloc(ent->data->value.str.val,
- ent->data->value.str.len + len + 1);
- strncpy(ent->data->value.str.val+ent->data->value.str.len, s, len);
- ent->data->value.str.len += len;
+ ent->data->value.str.len + decoded_len + 1);
+ strncpy(ent->data->value.str.val+ent->data->value.str.len, decoded_value,
decoded_len);
+ ent->data->value.str.len += decoded_len;
ent->data->value.str.val[ent->data->value.str.len] = '\0';
}
+
+ efree(decoded_value);
break;
case ST_NUMBER:
@@ -722,7 +733,7 @@
st_entry *ent;
wddx_stack_init(&stack);
- parser = XML_ParserCreate(NULL);
+ parser = XML_ParserCreate("ISO-8859-1");
XML_SetUserData(parser, &stack);
XML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element);