hhctrl.ocx: Add support for the CHM code page.
diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index f040e5d..f051feb 100644 --- a/dlls/hhctrl.ocx/chm.c +++ b/dlls/hhctrl.ocx/chm.c
@@ -133,6 +133,13 @@ heap_free(chm->defTitle); chm->defTitle = strdupnAtoW(buf, entry.len); break; + case 0x4: + /* TODO: Currently only the Locale ID is loaded from this field */ + TRACE("Locale is: %d\n", *(LCID*)&buf[0]); + if(!GetLocaleInfoW(*(LCID*)&buf[0], LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, + (WCHAR *)&chm->codePage, sizeof(chm->codePage)/sizeof(WCHAR))) + chm->codePage = CP_ACP; + break; case 0x5: TRACE("Default window is %s\n", debugstr_an(buf, entry.len)); break; @@ -416,6 +423,7 @@ if (!(ret = heap_alloc_zero(sizeof(CHMInfo)))) return NULL; + ret->codePage = CP_ACP; if (!(ret->szFile = strdupW(szFile))) { heap_free(ret);
diff --git a/dlls/hhctrl.ocx/content.c b/dlls/hhctrl.ocx/content.c index e0ec794..d246c49 100644 --- a/dlls/hhctrl.ocx/content.c +++ b/dlls/hhctrl.ocx/content.c
@@ -50,7 +50,7 @@ } } -static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text) +static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page) { const char *ptr; LPWSTR *param, merge; @@ -89,11 +89,11 @@ const char *local = strstr(ptr, "::")+2; int local_len = len-(local-ptr); - item->local = decode_html(local, local_len); + item->local = decode_html(local, local_len, code_page); param = &merge; } - *param = decode_html(ptr, len); + *param = decode_html(ptr, len, code_page); if(param == &merge) { SetChmPath(&item->merge, hhc_root->merge.chm_file, merge); @@ -151,7 +151,7 @@ if(!strcasecmp(node_name.buf, "/object")) break; if(!strcasecmp(node_name.buf, "param")) - parse_obj_node_param(item, hhc_root, node.buf); + parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage); strbuf_zero(&node); }
diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c index 1726f05..ef41ec2 100644 --- a/dlls/hhctrl.ocx/help.c +++ b/dlls/hhctrl.ocx/help.c
@@ -1793,7 +1793,7 @@ /* * Decode a string containing HTML encoded characters into a unicode string. */ -WCHAR *decode_html(const char *html_fragment, int html_fragment_len) +WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page) { const char *h = html_fragment; char *amp, *sem, symbol, *tmp; @@ -1850,9 +1850,9 @@ tmp_len += len; tmp[tmp_len++] = 0; /* NULL-terminate the string */ - len = MultiByteToWideChar(CP_ACP, 0, tmp, tmp_len, NULL, 0); + len = MultiByteToWideChar(code_page, 0, tmp, tmp_len, NULL, 0); unicode_text = heap_alloc(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, tmp, tmp_len, unicode_text, len); + MultiByteToWideChar(code_page, 0, tmp, tmp_len, unicode_text, len); heap_free(tmp); return unicode_text; }
diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h index 599b6a5..73b2a6b 100644 --- a/dlls/hhctrl.ocx/hhctrl.h +++ b/dlls/hhctrl.ocx/hhctrl.h
@@ -106,6 +106,8 @@ WCHAR *defTopic; WCHAR *defTitle; WCHAR *defToc; + + UINT codePage; } CHMInfo; #define TAB_CONTENTS 0 @@ -193,7 +195,7 @@ LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN; -WCHAR *decode_html(const char *html_fragment, int html_fragment_len); +WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page); /* memory allocation functions */
diff --git a/dlls/hhctrl.ocx/index.c b/dlls/hhctrl.ocx/index.c index 3b5053a..3cf69de 100644 --- a/dlls/hhctrl.ocx/index.c +++ b/dlls/hhctrl.ocx/index.c
@@ -62,7 +62,7 @@ * sub-topic then there isn't really a sub-topic, the index will jump * directly to the requested item. */ -static void parse_index_obj_node_param(IndexItem *item, const char *text) +static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT code_page) { const char *ptr; LPWSTR *param; @@ -109,7 +109,7 @@ return; } - *param = decode_html(ptr, len); + *param = decode_html(ptr, len, code_page); } /* Parse the object tag corresponding to a list item. @@ -137,7 +137,7 @@ TRACE("%s\n", node.buf); if(!strcasecmp(node_name.buf, "param")) { - parse_index_obj_node_param(item, node.buf); + parse_index_obj_node_param(item, node.buf, info->pCHMInfo->codePage); }else if(!strcasecmp(node_name.buf, "/object")) { break; }else {