From 613f88393960853513873756933bd23b93543a33 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 30 Sep 2007 21:10:50 +0000 Subject: DOM Strings are now capable of containing either UTF-8 or UTF-16 encoded data. The charset used for strings within a document is specified at document creation time. Whilst it is possible to mix charsets within a document, it's not recommended. Things that need fixing: + dom_string_get_data() doesn't return the charset. Better would be to permit the client to request a charset for the data to be returned in. + Interned node name strings will break if the document is UTF-16 (dom_document_create()). In fact, these could quite happily be globals, rather than allocating a set for each document. + Other usage of dom string constructors need checking for sanity + DOM Strings need to gain more utility APIs (such as getting the character length of a string, string concatenation etc). svn path=/trunk/dom/; revision=3614 --- bindings/xml/xmlbinding.c | 5 ++++- bindings/xml/xmlparser.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'bindings') diff --git a/bindings/xml/xmlbinding.c b/bindings/xml/xmlbinding.c index fbdc4c9..7b2475e 100644 --- a/bindings/xml/xmlbinding.c +++ b/bindings/xml/xmlbinding.c @@ -39,6 +39,7 @@ static dom_exception xml_dom_implementation_create_document( struct dom_string *qname, struct dom_document_type *doctype, struct dom_document **doc, + dom_string_charset charset, dom_alloc alloc, void *pw); static dom_exception xml_dom_implementation_get_feature( struct dom_implementation *impl, @@ -237,6 +238,7 @@ dom_exception xml_dom_implementation_create_document_type( * \param qname The qualified name of the document element * \param doctype The type of document to create * \param doc Pointer to location to receive result + * \param charset The charset to use for strings in the document * \param alloc Memory (de)allocation function * \param pw Pointer to client-specific private data * \return DOM_NO_ERR on success, @@ -273,13 +275,14 @@ dom_exception xml_dom_implementation_create_document( struct dom_string *qname, struct dom_document_type *doctype, struct dom_document **doc, + dom_string_charset charset, dom_alloc alloc, void *pw) { struct dom_document *d; dom_exception err; /* Create document object */ - err = dom_document_create(impl, alloc, pw, &d); + err = dom_document_create(impl, charset, alloc, pw, &d); if (err != DOM_NO_ERR) return err; diff --git a/bindings/xml/xmlparser.c b/bindings/xml/xmlparser.c index 6f1516b..9541a7c 100644 --- a/bindings/xml/xmlparser.c +++ b/bindings/xml/xmlparser.c @@ -182,6 +182,7 @@ xml_parser *xml_parser_create(const char *enc, const char *int_enc, /* Create key for user data registration */ err = dom_string_create_from_ptr_no_doc((dom_alloc) alloc, pw, + DOM_STRING_UTF8, (const uint8_t *) "__xmlnode", SLEN("__xmlnode"), &parser->udkey); if (err != DOM_NO_ERR) { @@ -194,6 +195,7 @@ xml_parser *xml_parser_create(const char *enc, const char *int_enc, /* Get DOM implementation */ /* Create a string representation of the features we want */ err = dom_string_create_from_ptr_no_doc((dom_alloc) alloc, pw, + DOM_STRING_UTF8, (const uint8_t *) "XML", SLEN("XML"), &features); if (err != DOM_NO_ERR) { dom_string_unref(parser->udkey); @@ -327,6 +329,7 @@ void xml_parser_start_document(void *ctx) /* qname */ NULL, /* doctype */ NULL, &doc, + DOM_STRING_UTF8, (dom_alloc) parser->alloc, parser->pw); if (err != DOM_NO_ERR) { -- cgit v1.2.3