0

I'm using the Javascript files outputted by GWT in a Windows 8.1 app, however as well as being UTF-8 encoded the files also need the Byte Order Mark at the start.

(See this question for why: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/dd352270-8790-4b48-8492-17a4a6875e99/why-the-utf8-with-bom-marker-requirement )


Not sure if it's relevant, but I'm building GWT using Maven.

Is there anything I can change in the Maven pom.xml file that will output the files encoded in UTF-8 with the BOM?

Or a change to GWT config file?


Thank you for your help, I've been trying to figure this one out all afternoon!

Jon Cox
  • 10,622
  • 22
  • 78
  • 123
  • Java itself does not recognize the BOM. http://stackoverflow.com/questions/4897876/reading-utf-8-bom-marker – Christian Kuetbach Dec 10 '13 at 18:48
  • 1
    I don't get why the BOM is needed. As far as I understand the Post, a BOM will just speedup some loadingtime. – Christian Kuetbach Dec 10 '13 at 18:54
  • Hi Christian, thank you for letting me know about Java & BOMs. The BOM is needed for the same reason as in this question http://stackoverflow.com/questions/15222182/how-do-i-add-a-bom-to-all-utf-8-files-in-a-project Basically to certify a Windows 8 app. – Jon Cox Dec 11 '13 at 13:27
  • Currently I'm working on a .bat script that will add it to the files. A bit of a hack but hopefully it will do the trick :) – Jon Cox Dec 11 '13 at 13:27

1 Answers1

0

Just in case anyone stumbles across this question in the future and wants an answer...

I couldn't find a way to do this with GWT, so I added some code to a .bat build script that runs.

Before running this script you will need to save an empty file (filewithbom.txt) that contains only the UTF-8 Byte Order Marker (0xEF 0xBB 0xBF if you're interested). This can be done by saving an empty file in Notepad, and being sure to set the encoding to UTF-8.

You will also want to change the CHANGE_DIR directory.

set OLD_DIR="%CD%"
set CHANGE_DIR="[PATH TO DIRECTORY WITH FILES TO CHANGE]"
set BOM_FILE="filewithbom.txt"
cd %CHANGE_DIR%
for /R %%f in (*.js, *.html) do (  
  type %BOM_FILE% >> tempfile.txt    
  type %%f >> tempfile.txt
  xcopy /Y tempfile.txt %%f
  del tempfile.txt
)
cd %OLD_DIR%

This loops through the CHANGE_DIR directory and it's subfolders, and adds the contents filewithbom.txt to the start of every file with a filename ending .js or .html.

Jon Cox
  • 10,622
  • 22
  • 78
  • 123