Cussedness
The natural cussedness of things in general.
-
JavaScript and UTF-8 in Eclipse
For some reason the usually excellent Eclipse IDE sets the default encoding of JavaScript files to ISO-8859-1, which is pretty much wrong and can be problematic. The correct path to configuring things so that they are right is rather non-obvious; Google failed me in the quest to fix things this time. It’s a small but irritating problem, and apparently I’m not alone in seeking an answer, so I’m posting my solution up here for future reference and for any other frustrated Eclipse JavaScripters that might be out there.
ECMAScript is supposed to support Unicode natively, so the default encoding for .js files should really be UTF-8 (or maybe UTF-16; as far as I know UTF-8 is fine, but I’m not an expert). I installed Eclipse via the PHP Development Tools project, so it may just be a problem with the configuration from that installer. Whatever the reason, it’s annoying if you’re trying to save a file with Unicode characters in it. Eclipse tells you that this is impossible, and to set the correct encoding on the file in question, but if you try to do that via File Properties, nothing changes. Here’s how to make Eclipse do what you want it to and save .js files in UTF-8.
Open Preferences→General→Content Types, then Text→JavaScript, and set “Default encoding” to “UTF-8″, like so:
Now you can save your JavaScript as UTF-8 just as the EMCA intended.
