Page 1 of 1

asc and chr

Posted: Sat Oct 14, 2017 8:05 pm
by rbytes
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.

Re: asc and chr

Posted: Sat Oct 14, 2017 8:13 pm
by Mr. Kibernetik
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.

Re: asc and chr

Posted: Sat Oct 14, 2017 8:19 pm
by Mr. Kibernetik
Similarly, it is possible to convert bytes to Unicode string with #.str function:

Code: Select all

a = [4Ah, 00h, 32h, 03h, 6Fh, 00h, 32h, 03h, 73h, 00h, 32h, 03h, E9h, 00h, 32h, 03h]
#.output(#.str(a))
Result:

J̲o̲s̲é̲

Re: asc and chr

Posted: Sat Oct 14, 2017 8:33 pm
by Mr. Kibernetik
This program prints emoticons:

Code: Select all

i = 1
> n, 0..ffh
  a[i] = n
  i += 1
  a[i] = 26h
  i += 1
<
#.output(#.str(a))
Result:

☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☔☕☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♈♉♊♋♌♍♎♏♐♑♒♓♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚇⚈⚉⚊⚋⚌⚍⚎⚏⚐⚑⚒⚓⚔⚕⚖⚗⚘⚙⚚⚛⚜⚝⚞⚟⚠⚡⚢⚣⚤⚥⚦⚧⚨⚩⚪⚫⚬⚭⚮⚯⚰⚱⚲⚳⚴⚵⚶⚷⚸⚹⚺⚻⚼⚽⚾⚿⛀⛁⛂⛃⛄⛅⛆⛇⛈⛉⛊⛋⛌⛍⛎⛏⛐⛑⛒⛓⛔⛕⛖⛗⛘⛙⛚⛛⛜⛝⛞⛟⛠⛡⛢⛣⛤⛥⛦⛧⛨⛩⛪⛫⛬⛭⛮⛯⛰⛱⛲⛳⛵⛶⛷⛸⛹⛺⛻⛼⛽⛾⛿

Re: asc and chr

Posted: Sat Oct 14, 2017 8:45 pm
by Mr. Kibernetik
Of course it can be done by just

Code: Select all

#.output("🤴")

Re: asc and chr

Posted: Sat Oct 14, 2017 8:54 pm
by rbytes
Thanks, Mr. K.
Windows has come a long way with characters! I will need to study this.

Re: asc and chr

Posted: Sat Oct 14, 2017 10:19 pm
by rbytes
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.

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))
<

Re: asc and chr

Posted: Sat Oct 14, 2017 10:36 pm
by Mr. Kibernetik
Because they are not text characters anymore but graphics symbols :D

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))
<
Снимок.JPG
Снимок.JPG (223.63 KiB) Viewed 3669 times

Re: asc and chr

Posted: Sat Oct 14, 2017 10:43 pm
by rbytes
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?

Re: asc and chr

Posted: Sat Oct 14, 2017 10:50 pm
by Mr. Kibernetik
rbytes wrote:
Sat Oct 14, 2017 10:43 pm
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?
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.