From d8edf07ed9e7a3e2f2ab43ffd2935b93326f2caa Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 15 Nov 2012 17:55:05 +0200 Subject: Bin use of UTF-16 expat variant in the Windows shell extension Thus we can drop that variant completely. Change-Id: I11a8e40436921219bd6dd4afad4c7907ccb6b84c --- shell/source/all/xml_parser.cxx | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'shell/source/all') diff --git a/shell/source/all/xml_parser.cxx b/shell/source/all/xml_parser.cxx index 54e1cffa5f41..23e43d5f8d6e 100644 --- a/shell/source/all/xml_parser.cxx +++ b/shell/source/all/xml_parser.cxx @@ -21,6 +21,12 @@ #include "internal/xml_parser.hxx" #include "internal/i_xml_parser_event_handler.hxx" +#ifdef _WIN32 +#include "internal/utilities.hxx" +#else +#define UTF8ToWString(s) s +#endif + #include namespace /* private */ @@ -96,12 +102,12 @@ static void xml_start_element_handler(void* UserData, const XML_Char* name, cons while(atts[i]) { - attributes[reinterpret_cast(get_local_name(atts[i]))] = reinterpret_cast(atts[i+1]); + attributes[UTF8ToWString(reinterpret_cast(get_local_name(atts[i])))] = UTF8ToWString(reinterpret_cast(atts[i+1])); i += 2; // skip to next pair } pDocHdl->start_element( - reinterpret_cast(name), reinterpret_cast(get_local_name(name)), attributes); + UTF8ToWString(reinterpret_cast(name)), UTF8ToWString(reinterpret_cast(get_local_name(name))), attributes); } } @@ -112,11 +118,13 @@ static void xml_end_element_handler(void* UserData, const XML_Char* name) xml_parser* pImpl = get_parser_instance(UserData); i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler(); if (pDocHdl) - pDocHdl->end_element(reinterpret_cast(name), reinterpret_cast(get_local_name(name))); + pDocHdl->end_element(UTF8ToWString(reinterpret_cast(name)), UTF8ToWString(reinterpret_cast(get_local_name(name)))); } static void xml_character_data_handler(void* UserData, const XML_Char* s, int len) { + static int count = 0; + assert(UserData); xml_parser* pImpl = get_parser_instance(UserData); @@ -124,10 +132,30 @@ static void xml_character_data_handler(void* UserData, const XML_Char* s, int le if (pDocHdl) { if (has_only_whitespaces(s,len)) - pDocHdl->ignore_whitespace(string_t(reinterpret_cast(s), len)); + pDocHdl->ignore_whitespace(UTF8ToWString(std::string(reinterpret_cast(s), len))); else - pDocHdl->characters(string_t(reinterpret_cast(s), len)); + pDocHdl->characters(UTF8ToWString(std::string(reinterpret_cast(s), len))); + } +#if 0 + if (count < 5) { + char buf[1000]; + sprintf(buf, + "%s: len=%d\n" + "s=%.10s\n" + "pDocHdl=%p has_only_whitespaces()=%d\n" + "string=%S", + "xml_character_data_handler", + len, + s, + pDocHdl, + has_only_whitespaces(s,len), + UTF8ToWString(std::string(reinterpret_cast(s), len)).c_str() + ); + + MessageBoxA(NULL, buf, "xml_character_data_handler", MB_OK); + count++; } +#endif } static void xml_comment_handler(void* UserData, const XML_Char* Data) @@ -137,7 +165,7 @@ static void xml_comment_handler(void* UserData, const XML_Char* Data) xml_parser* pImpl = get_parser_instance(UserData); i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler(); if (pDocHdl) - pDocHdl->comment(reinterpret_cast(Data)); + pDocHdl->comment(UTF8ToWString(reinterpret_cast(Data))); } } // extern "C" -- cgit