asc and chr
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
asc and chr
I would like to see the functions #.asc() and #.chr() added. I don't know if there are emoji characters available in Windows, but there should be some symbol characters that would be useful. To find them, we could built an SPL ASCII character display and selection program using these functions.
The only thing that gets me down is gravity...
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
In SPL working with characters is much more sophisticated. It works with Unicode characters of different complexity.
You can check "rosetta\string length.txt" program example to see how SPL treats characters. Simple ASC() function is not enough.
You can check "rosetta\string length.txt" program example to see how SPL treats characters. Simple ASC() function is not enough.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
Similarly, it is possible to convert bytes to Unicode string with #.str function:
Result:
J̲o̲s̲é̲
Code: Select all
a = [4Ah, 00h, 32h, 03h, 6Fh, 00h, 32h, 03h, 73h, 00h, 32h, 03h, E9h, 00h, 32h, 03h]
#.output(#.str(a))
J̲o̲s̲é̲
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
This program prints emoticons:
Result:
☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾⚀⚁⚂⚃⚄⚅⚆⚇⚈⚉⚊⚋⚌⚍⚎⚏⚐⚑⚒⚔⚕⚖⚗⚘⚙⚚⚛⚜⚝⚞⚟⚠⚢⚣⚤⚥⚦⚧⚨⚩⚬⚭⚮⚯⚰⚱⚲⚳⚴⚵⚶⚷⚸⚹⚺⚻⚼⚿⛀⛁⛂⛃⛆⛇⛈⛉⛊⛋⛌⛍⛏⛐⛑⛒⛓⛕⛖⛗⛘⛙⛚⛛⛜⛝⛞⛟⛠⛡⛢⛣⛤⛥⛦⛧⛨⛩⛫⛬⛭⛮⛯⛰⛱⛴⛶⛷⛸⛹⛻⛼⛾⛿
Code: Select all
i = 1
> n, 0..ffh
a[i] = n
i += 1
a[i] = 26h
i += 1
<
#.output(#.str(a))
☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾⚀⚁⚂⚃⚄⚅⚆⚇⚈⚉⚊⚋⚌⚍⚎⚏⚐⚑⚒⚔⚕⚖⚗⚘⚙⚚⚛⚜⚝⚞⚟⚠⚢⚣⚤⚥⚦⚧⚨⚩⚬⚭⚮⚯⚰⚱⚲⚳⚴⚵⚶⚷⚸⚹⚺⚻⚼⚿⛀⛁⛂⛃⛆⛇⛈⛉⛊⛋⛌⛍⛏⛐⛑⛒⛓⛕⛖⛗⛘⛙⛚⛛⛜⛝⛞⛟⛠⛡⛢⛣⛤⛥⛦⛧⛨⛩⛫⛬⛭⛮⛯⛰⛱⛴⛶⛷⛸⛹⛻⛼⛾⛿
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
Of course it can be done by just
Code: Select all
#.output("🤴")
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: asc and chr
Thanks, Mr. K.
Windows has come a long way with characters! I will need to study this.
Windows has come a long way with characters! I will need to study this.
The only thing that gets me down is gravity...
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: asc and chr
Here is a slight modification of the code that draws the text instead of outputting to the console
Another surprise - for me, anyway. The characters lose their colors.
Another surprise - for me, anyway. The characters lose their colors.
Code: Select all
i = 1
> n, 0..ffh
a[i] = n
i += 1
a[i] = 26h
i += 1
<
#.fontsize(60)
> t, 1..300,30
#.drawtext(10,50+t*2.4,#.mid(#.str(a),t,20))
<
- Attachments
-
- Screenshot (100).png (278.81 KiB) Viewed 3664 times
The only thing that gets me down is gravity...
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
Because they are not text characters anymore but graphics symbols
Code: Select all
i = 1
> n, 0..ffh
a[i] = n
i += 1
a[i] = 26h
i += 1
<
#.fontsize(60)
> t, 1..300,30
#.drawcolor(#.hsv2rgb(t/300*360,1,1):3)
#.drawtext(10,50+t*2.4,#.mid(#.str(a),t,20))
<
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: asc and chr
I found a link to the Windows Unicode table:
https://unicode-table.com/en/
One of the characters it shows is a checkmark ✓. This would make a good indicator for multiple selections in a list.
It didn't appear in the output when I ran your code above. What upper limit should the loop be set for to output the entire Unicode table?
https://unicode-table.com/en/
One of the characters it shows is a checkmark ✓. This would make a good indicator for multiple selections in a list.
It didn't appear in the output when I ran your code above. What upper limit should the loop be set for to output the entire Unicode table?
The only thing that gets me down is gravity...
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: asc and chr
There is no upper limit. Unicode table is more than 65000 character codes. In the code above there are only 256 characters with codes from 2600 to 26FF.rbytes wrote: ↑Sat Oct 14, 2017 10:43 pmI found a link to the Windows Unicode table:
https://unicode-table.com/en/
One of the characters it shows is a checkmark ✓. This would make a good indicator for multiple selections in a list.
It didn't appear in the output when I ran your code above. What upper limit should the loop be set for to output the entire Unicode table?