Category talk:Wren-str: Difference between revisions
Content added Content deleted
(→Source code: Bug fix) |
(→Source code: Added Greek class.) |
||
Line 560: | Line 560: | ||
return (b0 & b4Mask) << 18 | (b[1] & mbMask) << 12 | (b[2] & mbMask) << 6 | (b[3] & mbMask) |
return (b0 & b4Mask) << 18 | (b[1] & mbMask) << 12 | (b[2] & mbMask) << 6 | (b[3] & mbMask) |
||
} |
} |
||
} |
|||
} |
|||
/* |
|||
'Greek' enables characters from the Greek alphabet to be found from their name. |
|||
These characters are often used as mathematical or scientific symbols. |
|||
*/ |
|||
class Greek { |
|||
// Returns a list of the names of all Greek letters in alphabetical order. |
|||
static names { |
|||
return [ |
|||
"alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", |
|||
"0iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi", |
|||
"rho", "sigma final", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega" |
|||
] |
|||
} |
|||
// Finds and returns a Greek lower case character from its name. |
|||
static lower(name) { |
|||
var ix = names.indexOf(name) |
|||
if (ix == -1) Fiber.abort("Name not found.") |
|||
return String.fromCodePoint(0x03b1 + ix) |
|||
} |
|||
// Finds and returns a Greek upper case character from its name. |
|||
static upper(name) { |
|||
var ix = names.indexOf(name) |
|||
if (ix == -1) Fiber.abort("Name not found.") |
|||
if (name == "sigma final") ix = ix + 1 |
|||
return String.fromCodePoint(0x0391 + ix) |
|||
} |
} |
||
}</lang> |
}</lang> |