Yow will discover the binary at
jsc within the Terminal.
So what are you able to do with
If you happen to run
An image is value a thousand phrases, so let me present you ways it may be used to resolve a easy downside. I just lately wanted to transform some strings in our Turkish localization of Frenzic to uppercase: the lowercase “i” was getting transformed to the dotless model.
toLocaleUpperCase() operate is the right means to do that, so I pulled
jsc out of my device bag and set to work. The primary problem was getting enter.
Fortunately, there’s a
readline() operate that takes keyboard enter and returns a worth. Unluckily, that enter isn’t within the encoding you’d anticipate it to be: characters are returned in ISO-8859-1 (Latin-1), not UTF-8. Bear in mind, there’s no doc occasion so the default encoding is used.
To workaround this limitation, you possibly can % escape the characters to UTF-16 after which decode them again into UTF-8 with this system:
var textual content = decodeURIComponent(escape(readline()));
(If any WebKit engineers are studying this, it will be good to have a command line choice like
Producing output is a bit completely different than a browser, too. You’ll be utilizing
print() as an alternative of
console.log(). To transform the textual content enter and show it, I used this:
There are just a few extra built-in capabilities that will show helpful, however thus far, I’ve solely wanted to learn and write textual content. It’s undocumented, however
jsc additionally takes commonplace enter and can be utilized as a shebang:
$ echo "print(1+2);" | jsc 3
Since that is doubtless code I’ll have to make use of once more, I created a Turkish.js file:
whereas (true) print('Turkish textual content?'); var textual content = decodeURIComponent(escape(readline())); print(textual content.toLocaleUpperCase('tr-TR')); print('-------------');
I can now run this any time with