UTF coding for JS-scripts
Moderators: winston, another_commander
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
UTF coding for JS-scripts
What is the recommended/compulsory/correct UTF coding for JS scripts in Oolite?
Additional question: where do I find out how a script is coded and how do I change it?
I am using special characters in strings which are used by the game. They are correctly displayed on my computer, both in the JS script and in-game. However, when Disembodied downloaded and opened the script, "ü" was displayed as "√º", "ë" was displayed as "√´", "é" was displayed as "√©", and "ï" was displayed as "√Ø" on his computer. We don't know yet how this affects the in-game display.
As we both are using a Mac, I am wondering what causes this incorrect display of special characters. As a long-suffering German Mac user I am used to incorrect conversion of Umlauts from Windows to Mac and vice versa, but between two Macs? Thus I'm wondering whether the UTF coding may have something to do with it.
Additional question: where do I find out how a script is coded and how do I change it?
I am using special characters in strings which are used by the game. They are correctly displayed on my computer, both in the JS script and in-game. However, when Disembodied downloaded and opened the script, "ü" was displayed as "√º", "ë" was displayed as "√´", "é" was displayed as "√©", and "ï" was displayed as "√Ø" on his computer. We don't know yet how this affects the in-game display.
As we both are using a Mac, I am wondering what causes this incorrect display of special characters. As a long-suffering German Mac user I am used to incorrect conversion of Umlauts from Windows to Mac and vice versa, but between two Macs? Thus I'm wondering whether the UTF coding may have something to do with it.
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: UTF coding for JS-scripts
I've just looked through a variety of scripts and windows Notepad++ reports most of them as encoded in ANSI. Some of your are in UTF-8 without BOM.
Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: UTF coding for JS-scripts
I have no definite answer. When I look in Xcode than 'unicode (UTF-8)' is the default coding. When I look at the individual files that is also true.Commander McLane wrote:As we both are using a Mac, I am wondering what causes this incorrect display of special characters. As a long-suffering German Mac user I am used to incorrect conversion of Umlauts from Windows to Mac and vice versa, but between two Macs? Thus I'm wondering whether the UTF coding may have something to do with it.
But than when I open those same files with 'Texteditor' and do a 'save as...' the default coding for saving is "western (mac OS roman)". When I save them explicit with 'Texteditor' as 'unicode (UTF-8)', the default coding for saving becomes 'unicode (UTF-8)'. So I have no idea what the coding difference it between saving by Xcode or texteditor.
Self I always use "Dashcode" for editing my JS scripts. That program is part of the developer package that is on your mac installation disk, when you not already have installed it. It has an explicit option to save as a JS file. Although I can't see what coding that exactly is.
On very rare occasions I have JS files that have an unknown coding according dascode and it refuses to read them in. In that case I use texteditor to re-saving it, after which it does load.
Anyhow, try dashcode for your JS work. It even indexes all defined functions in the script in the top bar for fast finding and accessing them.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: UTF coding for JS-scripts
I am using Dashcode. The strange conversion happens when Disembodied opens the file with TextEdit.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: UTF coding for JS-scripts
The files are correctly encoded in UTF-8. TextEdit’s “automatic” encoding is too stupid to automatically detect UTF-8 (which is a bug; doing it is easy and very reliable). Using File→Open and selecting UTF-8 from the pop-up menu at the bottom should fix it.
E-mail: [email protected]
- Disembodied
- Jedi Spam Assassin
- Posts: 6885
- Joined: Thu Jul 12, 2007 10:54 pm
- Location: Carter's Snort
Re: UTF coding for JS-scripts
I get the same dodgy characters when opening the files with SubEthaEdit, too ... the default setting for opening files there is called "recommended by mode". Switching to UTF-8 in SubEthaEdit displays the correct characters though.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: UTF coding for JS-scripts
TextEdit may have bugs, but looking at this, I noticed it had a preference to use smart quotes. I activated this, and it was the first mac program I ever saw that does it right in the Dutch version. In the Netherlands the starting and ending quote are identical. An upside down quote is not part of the Dutch language, but still all dutch versions of software with a smart quote option start with an “ quote. Bad localisation in my opinion. However you do see this wrong quotation more often now in some newspapers, probably because writers don't correct their word processor.Commander McLane wrote:The strange conversion happens when Disembodied opens the file with TextEdit.
Just out of curiosity I switched my system to english and restarted TextEdit. In english it also quotes in the Dutch way. So it is not better than other programs in this, but just does it accidentally right for the Dutch language.
NB from the quoting in above two messages I should conclude that Ahruman is not Dutch and Disembodied is
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Disembodied
- Jedi Spam Assassin
- Posts: 6885
- Joined: Thu Jul 12, 2007 10:54 pm
- Location: Carter's Snort
Re: UTF coding for JS-scripts
Not quite, although I plan to inflict some Amsterdamage on myself in the next week or so ... non-smart quotes would seem to be the default on Safari, and I can't be bothered using the keyboard shortcuts (alt-[ for “, alt-shift-[ for ”, alt-] for ‘ and alt-shift-] for ’). The biggest pain I've found with "smart quotes" (or rather, “smart quotes”) is in setting Gaelic text. It's quite common for Gaelic sentences to start ’S, which – if the author has used the apostrophe key, a “smart quoter” with a UK setting will render as ‘S ...Eric Walch wrote:NB from the quoting in above two messages I should conclude that Ahruman is not Dutch and Disembodied is
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: UTF coding for JS-scripts
I was completely wrong. It is not accidentally that TextEdit does it right. It is a system preference the user can edit how he wants it. You can even set the single quotes different than the double quotes or even replace them by , or <. I just forgot I once did set them. TextEdit is just the only one I've seen that respects the system preferences.Eric Walch wrote:Just out of curiosity I switched my system to english and restarted TextEdit. In english it also quotes in the Dutch way. So it is not better than other programs in this, but just does it accidentally right for the Dutch language.
Programs like Filemaker and Pages, that I use much, ignore these system preferences. Even when both are very Mac friedly programs and Pages is part of i-works.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: UTF coding for JS-scripts
Almost every feature of TextEdit is actually a feature ofEric Walch wrote:I was completely wrong. It is not accidentally that TextEdit does it right. It is a system preference the user can edit how he wants it. You can even set the single quotes different than the double quotes or even replace them by , or <. I just forgot I once did set them. TextEdit is just the only one I've seen that respects the system preferences.
NSTextView
. (The source code for TextEdit is in /Developer/Examples.) You can enable system-standard smart quotes (and spelling and grammar correction, and various other things) in most text fields from the contextual menu.E-mail: [email protected]