In JavaScript I can do this:
foo = "\u2669" // 1/4 note
But I can't do this
foo = "\u1D15D" // full note -five hex digits
It will be interpreted as "\u1D15" followed by "D"
Are there any workarounds for this?
UPDATE 2012-07-09: The proposal for ECMAScript Harmony now includes support for all Unicode characters.
I did a little checking and it appears that there is no full note near
0x2669
. (table of unicode chars)Although using
0x01D15D
does give me a unknown unicode character this could be because I don't have a music font though. Javascript will try to parse as byte as it can and0x1D15D
is 2.5 bytes padding it with a0
will make it 3 and parsable.Also this was quite handy: unicode.org/charts/PDF/U1D100.pdf
Try putting the unicode between curly braces:
'\u{1D15D}'
.In the MDN documentation for fromCharCode, they note that javascript will only naturally handle characters up to 0xFFFF. However, they also have an implementation of a fixed method for fromCharCode that may do what you want (reproduced below):
You can use this:
Example: