Skip to content


Unicode Script property and Javascript

Dear lazyweb,

I would like a Javascript function to work like this:

magicalFunction('カ')
→ 'Katakana'

magicalFunction('a')
→ 'Latin'

magicalFunction('አ')
→ 'Ethiopic'

In other words, I want to be able to access the script property described in UAX #24: Script Names.

in Unicode Script property and Javascript

There you go.The script was machine-produced from Unicode’s Scripts.txt file. The REALBasic code read all relevant lines and compiled codepoint ranges, optimized if possible (ie if lines in sequence cover an uninterrupted range), which are then translated into javascript if () code. The code could and should be optimized further — some ranges are actually on just one codepoint — and the ranges could probably be optimized. But it works…

Posted in Code, General, JavaScript.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.