I am using msxsl.exe to generate HTML file dynamically from an XML and XSL. I have written the code in C++ using CreateProcess API and calling msxsl.exe in that. Since the output was UTF8 in Windows 7, I created all associated files(like CSS and JavaScript) in same encoding. Everything was working fine. When I am running the same application in Windows 10 (LTSC), the JavaScript was not loaded as the HTML is now generated with UCS-2LE BOM encoding. I tried calling SetConsoleOutputCP(CP_UTF8) just before creating the process. This didn't solved my issue. How could I get the UTF8 output irrespective of the OS?
HTML files accept JavaScript with same encoding as the HTML file itself. This is the default behavior. When using JavaScript with another encoding, the charset attribute of <script>
tag can be used(HTML script charset Attribute).
So adding charset attribute like shown below I could fix the type of JavaScript in all OS, irrespective of the HTML encoding.
<script type="text/javascript" src="MyJavaScript.js" charset="UTF-8"></script>