Page 1 of 1
Inserting Unicode symbol
Posted: Sun Aug 22, 2021 11:44 pm
by michaelk
What is the best way to insert a Unicode symbol such as a musical flat sign (U+266D) into text produced by Dyalog APL?
Re: Inserting Unicode symbol
Posted: Mon Aug 23, 2021 8:07 am
by Morten|Dyalog
You can use the function ⎕UCS to generate Unicode characters from code points, in this case that would be (⎕UCS 9837). Depending on your environment, you may simply be able to cut and paste the symbol into character constants, '♭' displays fine for me under Windows.
Re: Inserting Unicode symbol
Posted: Mon Aug 23, 2021 8:50 am
by michaelk
Thanks, Morten. Where is the [UCS] table that assigns 9837 to the flat symbol?
Re: Inserting Unicode symbol
Posted: Mon Aug 23, 2021 9:00 am
by Morten|Dyalog
9837 is the decimal equivalent of 266D that you had found yourself. There is a user command to do conversions, if you don't have a hex calculator handy:
Re: Inserting Unicode symbol
Posted: Sun Aug 29, 2021 7:16 am
by Adam|Dyalog
You can also use any 4-digit hexadecimal code (0000–FFFF) directly via the ⎕JSON system function:
⎕JSON'"\u266D"' ⍝ note the inner "double-quotes"
♭
For added convenience, and to handle less than 4 digits, we can define:
U←{0 ⎕JSON 1⌽'""\u',¯4↑'000',⍕⍵}
U'266D'
♭