Post Reply 
Unicode char comparison puzzle
05-31-2018, 01:23 PM
Post: #8
RE: Unicode char comparison puzzle
Thanks for the tips re comparing lists with EQ and DIMGROB usage. I've incorporated those changes, though then decided to render onto the main screen G0 to serve as a visual progress indicator, together with a percentage done.

Code:

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

LOCAL BLACK:=#000000, WHITE:=#FFFFFF, YELLOW:=#FFFF00;
LOCAL CHAR_WIDTH:=100, CHAR_HEIGHT:=5;

bit_signature_for_char(c)
BEGIN
  local result={}, x, y, pix;
  TEXTOUT_P(c,G0,0,0,2,#000000,100,#FFFFFF);
  for y from 0 to CHAR_HEIGHT do  // should probably compare more rows of pixels
    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;

disp_current(cp,perc)
BEGIN
  RECT_P(G0,20,0,95,12,YELLOW);
  TEXTOUT_P(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:=#26FFh, perc;
PRINT();
FOR cp FROM start TO finish DO
  perc:=IP((cp-start)/(finish-start)*100);
  disp_current(cp,perc);
  //IF CHAR(cp) ≠ "⛾" THEN  // doesn't work 
  IF NOT same_char(CHAR(cp), CHAR(#2600)) THEN  // works :-)
    S := S + CHAR(cp);
  END;
END;
PRINT(S);
END;

More programming questions:
  • Is there a way to TEXTOUT an integer in hex?
  • Do we know the exact height and width of characters in pixels? (Both in font size 1 & 2)
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: 3 Guest(s)