Musical Note Unicode Symbol

Does anyone know which Unicode extension I need to add a musical note symbol to my text or if that will work at all?

Unicode Full Character Names by Graham Nelson comes to mind for this. However, it’s massive and you’re unlikely to use almost all of it.

If you know the decimal value for the unicode character, you can use this instead.

say "[unicode (decimal number)]";

If you’d rather put a name to the unicode character. You can do so like this.

musical note of translates into Unicode as (decimal number).

Then you can just use this.

say "[unicode musical note]";

Check out 5.11 and 27.25 in the “Writing with Inform” handbook for more details.

Hope this helps.

You probably have your desired musical note in Unicode already, but just in case, here’s a PDF of all the music-related symbols.

2 Likes

That PDF just reminded me that Inform can’t handle 5 digit hex Unicode characters (higher than 65535 in decimal). So unfortunately these can’t be used in Inform (yet).

Yeah, I couldn’t get it to work.

Note also that some interpreters reproduce by default only a small subset of even the very low unicode points, which has bit me hard in the past.

2 Likes

Very true! Incidentally, I have an inform extension dedicated to solving just that issue where you can type “unicode off” and “unicode on” to toggle unicode mode and a table of predefined ASCII substitutes for unicode characters when unicode is off.

1 Like

Yeah, unfortunately a lot of software only supports the “Basic Multilingual Plane” of Unicode, and that includes Inform. So no emojis allowed.

But! There are a couple of musical note symbols that did find their way into the Basic Multilingual Plane, and can be used! The most widely-supported of these are Unicode 9834 (U+266A) for an eighth note ♪, and Unicode 9835 (U+266B) for beamed eighth notes ♫. So you can try those ones and see what the interpreter thinks! (9833 is a quarter note and 9836 is beamed sixteenth notes, but those are a lot less supported.)

1 Like

Note that the next release of Inform will have support for the SMP.

1 Like

You can print emojis with the decimal codepoint (even if > 65535) if you drop down to I6 and use print (char) c

[ A simple emoji (1 code point). ]
To say emoji (code point - number):
	say code point as unicode;

To say (N - a number) as unicode: (-
	if (glk_gestalt(gestalt_CharOutput, {N}) == gestalt_CharOutput_ExactPrint) {
		print (char) {N};
	}
-)

When play begins:
	say "[emoji 127925]";
	say "[emoji 129688]";
	say "[emoji 129345]"; 
	say "[emoji 129671]";
	say "[emoji 127932]";
	say "[emoji 129672]";
	say "[emoji 127926]";
	say "[emoji 127927]"; 
	say "[emoji 127928]"; 
	say "[emoji 127929]"; 
	say "[emoji 127930]";

image

You can even print emojis with multiple codepoints by joining them with a “zero width joiner”.

I have an extension that does this but I’m a bit conflicted: I don’t remember having a good enough understanding of these things to have written it myself. It’s not that complicated so it’s possible I learned enough to make it work and then forgot about it but it’s also possible I cobbled together bits of code found elsewhere and it’s not my code :man_shrugging:

When play begins:
	[ That's not an addition, that's just + as an argument separator. ]
	say "[emoji 128104 + 128105 + 128103 + 128102][line break]";
	say "[emoji 128693 + 127999 + 9792][line break]";
	say "[emoji 128104] [emoji 128104 + 127997][line break]";

But it doesn’t work everywhere.
In Quixe:
image

In the IDE (on MacOS):
image

Code is here: Emojis extension for Inform 7 · GitHub

1 Like

Might want to test in different more-popular interpreters. I got bit by like, Gargoyle, with what was a fairly common symbol.

Daniel! That’s it. Both of those codes work. They are also not even close to the codes that I found. Thank you!!!

1 Like