Jacek Caban (@jacek) commented about dlls/mshtml/script.c:
return S_OK; }
- switch(bsc->bsc.bom) { - case BOM_UTF16: + bom = bsc->bsc.bom; + if(bom == BOM_NONE) { + /* FIXME: Try to use charset from HTTP headers first */ + + /* IE guesses the encoding here using heuristics. Since valid script must start with an + * ASCII char (keyword, comment slash, string literal char, etc) that should be enough. */ + if(bsc->bsc.read > sizeof(WCHAR) && *(WCHAR*)bsc->buf < 128) + bom = BOM_UTF16; + else + cp = get_document_charset(bsc->script_elem->element.node.doc);
You could leave the switch statement as it was and just handle the `BOM_NONE` to `BOM_UTF16` fixup here. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7360#note_105247