Post Reply 
Unicode char comparison puzzle
06-01-2018, 10:35 AM
Post: #15
RE: Unicode char comparison puzzle
Ok here is the new faster version - to view different ranges of characters just edit the code.

Code:

// Unicode dump of unique chars
// Version 3, Andy Bulka (tcab) 2018

LOCAL boring_glyph_sig:={};
LOCAL BLACK:=#000000, WHITE:=#FFFFFF, YELLOW:=#FFFF00;
//LOCAL CHAR_WIDTH:=12, CHAR_HEIGHT:=5;  // char width seems to be about 12 but TW says it varies
LOCAL CHAR_WIDTH:=3, CHAR_HEIGHT:=2;  // cheaper comparison, don't scan all pixels
 
bit_signature_for_char(c)
BEGIN
  local result={}, x, y, pix,width;
  TEXTOUT_P(c,G0,0,0,2,#000000,100,#FFFFFF);
  for y from 0 to CHAR_HEIGHT do
    for x from 0 to CHAR_WIDTH do
      result := concat(result, GETPIX_P(G0,x, y));
    end;
  end;
  return result;
END;

same_char(c1, c2)
BEGIN
  return EQ(bit_signature_for_char(c1),
                 bit_signature_for_char(c2));
END;

can_render(c1)
BEGIN
  return NOT EQ(bit_signature_for_char(c1),
                           boring_glyph_sig);
END;

disp_progress(cp,perc)
BEGIN
  RECT_P(G0,20,0,95,12,YELLOW);
  TEXTOUT_P(R→B(cp),G0,20,0,2,BLACK,200,WHITE); // disp candidate codepoint number
  TEXTOUT_P(perc+"%",G0,70,0,2,BLACK,200,YELLOW); // disp percent done
END;

EXPORT UNIFUN()
BEGIN
  //LOCAL cp, S:="", start:=#2600h, finish:=#260Ah, perc;  // a short range of chars
  LOCAL cp, S:="", start:=#2600h, finish:=#26FFh, perc;    // larger range of chars
  //LOCAL cp, S:="", start:=#2500h, finish:=#28FFh, perc;    // even larger range of chars
  PRINT();
  boring_glyph_sig:=bit_signature_for_char(CHAR(#2600));
  FOR cp FROM start TO finish DO
    perc:=IP((cp-start)/(finish-start)*100);
    disp_progress(cp,perc);
    //IF NOT same_char(CHAR(cp), CHAR(#2600)) THEN  // slow
    IF can_render(CHAR(cp)) THEN  // faster
      S := S + CHAR(cp);
    END;
  END;
  PRINT(S);
END;

The progress indicator now displays in hex, too.

Quote:I'm a bit curious what is wrong or missing from the existing character browser? What are you trying to accomplish that isn't done there?

The Prime character browser is great - nothing missing there. I just happened to be looping through some characters one day on the Prime and wondered how I could filter out dud characters, and, well, one thing led to another. :-) Just learning... about unicode, pixels, coordinate systems, grobs, hex format, comparing lists, TEXTOUT, character widths & optimisation. Love it - the Prime sure is a powerful calculator - a well thought out design appropriate to the times we live in (touchscreen, unicode, grobs, algebraic, structured programming, rechargeable, free connectivity kit/editor/emulator, iPhone versions etc.).

Andy
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Unicode char comparison puzzle - tcab - 05-30-2018, 12:50 PM
RE: Unicode char comparison puzzle - tcab - 05-31-2018, 01:34 AM
RE: Unicode char comparison puzzle - Tyann - 05-31-2018, 04:29 AM
RE: Unicode char comparison puzzle - tcab - 05-31-2018, 01:23 PM
RE: Unicode char comparison puzzle - Tyann - 06-01-2018, 04:30 AM
RE: Unicode char comparison puzzle - tcab - 06-01-2018, 07:48 AM
RE: Unicode char comparison puzzle - tcab - 06-01-2018 10:35 AM



User(s) browsing this thread: 1 Guest(s)