Unicode Viewer

Post Reply
User avatar
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: Canada
Contact:

Unicode Viewer

Post by rbytes »

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.

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)
<
<-
Attachments
Screenshot (110).png
Screenshot (110).png (338.67 KiB) Viewed 3611 times
whbutt.png
whbutt.png (16.86 KiB) Viewed 3611 times
transp.png
transp.png (854 Bytes) Viewed 3615 times
greenbutt.png
greenbutt.png (6.65 KiB) Viewed 3615 times
yellowbutt.png
yellowbutt.png (6.58 KiB) Viewed 3615 times
bluebutt.png
bluebutt.png (6.61 KiB) Viewed 3615 times
redbutt.png
redbutt.png (6.55 KiB) Viewed 3615 times
grbutt.png
grbutt.png (15.9 KiB) Viewed 3615 times
Last edited by rbytes on Fri Oct 20, 2017 2:54 pm, edited 1 time in total.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Unicode Viewer

Post by Mr. Kibernetik »

Very serious application.
This is what I get on my screen:
Снимок.JPG
Снимок.JPG (141.66 KiB) Viewed 3604 times

User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

Re: Unicode Viewer

Post by Dav »

Looks like a nice handy app! I'll have to try this when I get my new Win10 tablet and install SPL.

- Dav

User avatar
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: Canada
Contact:

Re: Unicode Viewer

Post by rbytes »

Thanks, Dav. Your Smart Basic ASCII program was an inspiration for the Unicode Viewer.

Mr. K, you are missing the bottom 4 buttons. Are you running the program on a laptop, a tablet or a phone? What is the screen size and aspect ratio?

I have not yet coded Unicode Viewer to scale the screen down to phone size. However, Windows tablets and laptops seem to vary a lot in aspect ratio. My next version of Unicode Viewer will scale it independently in the horizontal and vertical to fit on any screen.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Unicode Viewer

Post by Mr. Kibernetik »

rbytes wrote:
Fri Oct 20, 2017 1:55 pm
Thanks, Dav. Your Smart Basic ASCII program was an inspiration for the Unicode Viewer.

Mr. K, you are missing the bottom 4 buttons. Are you running the program on a laptop, a tablet or a phone? What is the screen size and aspect ratio?

I have not yet coded Unicode Viewer to scale the screen down to phone size. However, Windows tablets and laptops seem to vary a lot in aspect ratio. My next version of Unicode Viewer will scale it independently in the horizontal and vertical to fit on any screen.
I am using a notebook with 1280 x 800 screen size. Also it seems that I am missing background buttons and now I see why - my images are in the same folder as the program. Seems that your images are taken simultaneously from different folders.
Of course if I run your application not full screen (in a window, which is typical for Windows applications) it will show only a fragment of application interface.

User avatar
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: Canada
Contact:

Re: Unicode Viewer

Post by rbytes »

Interesting - your laptop is almost identical in resolution to my virtual resolution of 1280 x 853. The height difference is probably why the bottom buttons were hidden.

Please try Unicode Viewer version 1.1.

I have coded it to check for screen size and adjust the layout. If you uncomment the #.output line near the start of the program, it will give you your virtual screen size, which as you know is sometimes different from the physical resolution. On your laptop it seems to be the same. All buttons should now be located in the FontView folder
The only thing that gets me down is gravity...

Post Reply