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 !
5 posts
• Page 1 of 1
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?
- michaelk
- Posts: 34
- Joined: Wed Feb 10, 2010 8:38 am
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.
-
Morten|Dyalog - Posts: 453
- Joined: Tue Sep 09, 2008 3:52 pm
Re: Inserting Unicode symbol
Thanks, Morten. Where is the [UCS] table that assigns 9837 to the flat symbol?
- michaelk
- Posts: 34
- Joined: Wed Feb 10, 2010 8:38 am
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
-
Morten|Dyalog - Posts: 453
- Joined: Tue Sep 09, 2008 3:52 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'
♭
-
Adam|Dyalog - Posts: 135
- Joined: Thu Jun 25, 2015 1:13 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group