#define groupSize (((Parser *)parser)->groupSize)
#define hadExternalDoctype (((Parser *)parser)->hadExternalDoctype)
-XML_Parser XML_ParserCreate(const char *encodingName)
+#ifdef XML_UNICODE
+static
+int translateToAscii(const XML_Char *from, char *to, size_t len, const char **p)
{
+ if (!from) {
+ *p = 0;
+ return 1;
+ }
+ *p = to;
+ for (;;) {
+ if (len-- == 0)
+ return 0;
+ *to++ = (char)*from;
+ if (*from == 0)
+ break;
+ if (*from >= 0x80)
+ return 0;
+ }
+ return 1;
+}
+#else /* not XML_UNICODE */
+#define translateToAscii(from, to, len, p) (*(p) = (from), 1)
+#endif /* not XML_UNICODE */
+
+XML_Parser XML_ParserCreate(const XML_Char *encodingName)
+{
+#ifdef XML_UNICODE
+ char encodingBuf[128];
+#endif
+ const char *asciiEncodingName;
XML_Parser parser = malloc(sizeof(Parser));
if (!parser)
return parser;
return 0;
}
dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
- if (!XmlInitEncoding(&initEncoding, &encoding, encodingName)) {
+ if (!translateToAscii(encodingName, encodingBuf, sizeof(encodingBuf),
+ &asciiEncodingName)
+ || !XmlInitEncoding(&initEncoding, &encoding, asciiEncodingName)) {
errorCode = XML_ERROR_UNKNOWN_ENCODING;
processor = errorProcessor;
}
XML_Parser XML_ExternalEntityParserCreate(XML_Parser oldParser,
const XML_Char *openEntityNames,
- const char *encodingName)
+ const XML_Char *encodingName)
{
XML_Parser parser = oldParser;
DTD *oldDtd = &dtd;
typedef void *XML_Parser;
#ifdef XML_UNICODE
-/* Not supported yet. */
+/* Information is UTF-16 encoded. */
#include <stddef.h>
typedef wchar_t XML_Char;
#else
or null if there is no externally specified encoding. */
XML_Parser XMLPARSEAPI
-XML_ParserCreate(const char *encoding);
+XML_ParserCreate(const XML_Char *encoding);
/* atts is array of name/value pairs, terminated by NULL;
XML_Parser XMLPARSEAPI
XML_ExternalEntityParserCreate(XML_Parser parser,
const XML_Char *openEntityNames,
- const char *encoding);
+ const XML_Char *encoding);
/* If XML_Parser or XML_ParseEnd have returned 0, then XML_GetError*
returns information about the error. */