Inserting Unicode symbol
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
Inserting Unicode symbol
What is the best way to insert a Unicode symbol such as a musical flat sign (U+266D) into text produced by Dyalog APL?
- Morten|Dyalog
- Posts: 460
- Joined: Tue Sep 09, 2008 3:52 pm
Re: Inserting Unicode symbol
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
Thanks, Morten. Where is the [UCS] table that assigns 9837 to the flat symbol?
- Morten|Dyalog
- Posts: 460
- Joined: Tue Sep 09, 2008 3:52 pm
Re: Inserting Unicode symbol
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:
Code: Select all
]fromhex 266D
9837
- Adam|Dyalog
- Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: Inserting Unicode symbol
You can also use any 4-digit hexadecimal code (0000–FFFF) directly via the ⎕JSON system function:
For added convenience, and to handle less than 4 digits, we can define:
⎕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'
♭