Unicode Viewer
Posted: Fri Oct 20, 2017 12:47 am
This program lets you view and select from more than 60,000 available Unicode characters. You step up and down through the characters with the Next and Prev buttons 128 characters at a time. Then press any character button. That button turns pale green, and its character is copied to the clipboard so you can paste it directly into your programs. This method is not recommended for programs you will be sharing though, because the Forum can't show most Unicode characters.
You will also see the low and high byte values needed to reproduce the character. They are displayed both in hexadecimal and decimal formats. Pressing Save saves a tiny file called "address.txt" that contains the low and high bytes in decimal format. Then you can run a separate program called "Show Unicode". It will read 'address.txt" and display the Unicode character very large, both as a text character and as a drawn character. Note that drawn characters lose any embedded color. Check the code of Show Unicode to see how to display Unicode characters in your own programs.
You will need all of the attached png buttons below. Put them in a folder called "Fontview".
One more thing. The box at the lower left shows the high byte address as a decimal. It points to the current location. It is set to start at 26h, which is 38 dec. This is an area of the Unicode table that contains some interesting and colourful emoticons.
I intend the user to be able to input new values from 0 to 254 inclusive, and move to that location in the Unicode table. But the textbox will not accept user input, and I don't know why. I have checked and rechecked the code, and will need Mr. K's help to resolve.
You will also see the low and high byte values needed to reproduce the character. They are displayed both in hexadecimal and decimal formats. Pressing Save saves a tiny file called "address.txt" that contains the low and high bytes in decimal format. Then you can run a separate program called "Show Unicode". It will read 'address.txt" and display the Unicode character very large, both as a text character and as a drawn character. Note that drawn characters lose any embedded color. Check the code of Show Unicode to see how to display Unicode characters in your own programs.
You will need all of the attached png buttons below. Put them in a folder called "Fontview".
One more thing. The box at the lower left shows the high byte address as a decimal. It points to the current location. It is set to start at 26h, which is 38 dec. This is an area of the Unicode table that contains some interesting and colourful emoticons.
I intend the user to be able to input new values from 0 to 254 inclusive, and move to that location in the Unicode table. But the textbox will not accept user input, and I don't know why. I have checked and rechecked the code, and will need Mr. K's help to resolve.
Code: Select all
''
Unicode Viewer by rbytes
October 2017
''
' hide the control menu - screenwidth increases by 48 points
#.scrview(#.normal)
' get screen size and calculate scaling for device
x,y = #.scrsize()he
rw = x/1280 ; rh = y/813
s = 1
i = 1
u = 0
r = 26h '00h '26h gives good emoticons
shft = 0
cp = 1
flag = 1
' draw title
#.fontsize(30)
#.fontname("Papyrus")
#.drawtext(466,25,"UNICODE VIEWER")
fn = "address.txt"
' create button template
h = #.button ; h.height = 70*rh
h.width = 100*rw ; h.y = 710*rh
h.fontsize = 22 ; h.fontname = "Papyrus"
h.fontcolor(1,1,1)
' create buttons from template
f,g,j,k = h ; f.x = 370*rw ; g.x = 820
j.x = 520*rw ; k.x = 670*rw
f.image = "Fontview/redbutt.png"
g.image = "Fontview/greenbutt.png"
j.image = "Fontview/bluebutt.png"
k.image = "Fontview/yellowbutt.png"
f.text = "STOP" ; g.text = "SAVE"
j.text = "PREV" ; k.text = "NEXT"
#.show(f,g,j,k)
' create textboxes to display selected character and address
d,e,ez = #.textbox
d.width = 80
d.height = 40
d.y = 674
d.text = ""
e,o = d
e.x = 610
o.x = 1030
d.x = 730
ez.x = 190
ez.y = 670
ez.edit = 1
ez.text = ""
ez.multi = 0
ez.width = 50
ez.height = 40
#.show(d,e,ez,o)
#.fontsize(18)
#.drawtext(605,640,"Hex Bytes")
#.drawtext(725,640,"Dec Bytes")
#.drawtext(1030,640,"Unicode #")
#.drawrect(510,660,570,720)
#.drawrect(610,670,690,710)
#.drawrect(730,670,810,710)
#.drawrect(1030,670,1110,710)
' create button matrix
' define template button and set common parameters
q=#.button
q.width = 60
q.height = 60
q.text = ""
q.fontsize = 32
q.image = "Fontview/whbutt.png"
' buttons to display short messages
w=#.button
w.image = "Fontview/transp.png"
p,m = w
p.fontsize = 36
w.fontsize = 20
m.fontsize = 20
p.text = ""
p.x = 510
p.y = 660
w.x = 300
m.x = 840
m.y,w.y = 670
#.show(p)
m.text = "Address saved"
w.text = "Copied to clipboard:"
' create 128 buttons in a 16 x 8 matrix
> t, 1..128
' create button name in array, copy from button template q
b[t] = q
' position and draw the buttons
a[i] = t-1
i += 1
a[i] = r '00h 26h
i += 1
~b[t].text = #.mid(#.str(a),t,1)
~b[t].x = 60 + s*65
~b[t].y = 100 + u*65
#.show(~b[t])
' form the rows
s += 1
? s > 16
s = 1
u += 1
.
<
' select button 1
c = ~b[1]
c.image = "grbutt.png"
flag = 1
p.text = c.text
d.text = 0 + shft + " " + r
'pr1 = "0"
'pr2 = ""
e.text = #.str(0 + shft,"x")+"h" + " " + #.str(r,"x")+"h"
o.text = 1 + shft + r*256
ez.text = r
' main program loop
>
? #.act(f) ' stop button
#.end()
.
? #.act(ez) ' textbox high byte entry
r = ez.text
shft = 0
#.output(r)
drawit <->
.
? #.act(g) ' save button
? #.fexist(fn), #.fdelete(fn)
#.writeline(fn,flag-1 + shft)
#.writeline(fn,r)
#.show(m)
#.delay(1)
#.hide(m)
.
? #.act(j) ' prev button; move down 128 bytes
? r > 00h
z.image = "whbutt.png"
? shft = 128
shft=0
!
r -= 01h
shft=128
.
''
c = ~b[1]
c.image = "grbutt.png"
flag = 1
p.text = c.text
d.text = 0 + shft + " " + r
''
drawit <->
.
.
? #.act(k) ' next button; move up 128 bytes
? r < ffh
z.image = "whbutt.png"
? shft = 0
shft=128
!
r += 01h
shft=0
.
''
c = ~b[1]
c.image = "grbutt.png"
flag = 1
p.text = c.text
d.text = 0 + shft + " " + r
''
drawit <->
.
.
> i, 1..#.size(b,1)
c = ~b[i]
? flag, z = ~b[flag]
? #.act(c)
c.image = "grbutt.png"
? flag, z.image = "whbutt.png"
p.text = c.text
d.text = i-1 + shft + " " + r
o.text = i-1 + shft + r * 256
e.text = #.str(i - 1 + shft,"x")+"h" + " " + #.str(r,"x")+"h"
flag = i
#.clipboard(c.text)
#.show(w)
#.delay(1)
#.hide(w)
.
<
#.relax()
<
:drawit
i = 1
ez.text = r
> t, 1..128
a[i] = t-1+shft
i += 1
a[i] = r '00h 26h
i += 1
~b[t].text = #.mid(#.str(a),t,1)
<
<-