Post Reply 
Unicode char comparison puzzle
05-31-2018, 01:34 AM
Post: #5
RE: Unicode char comparison puzzle
Thanks for the responses.

So the problem is that I want to filter out all the unicode chars/codepoints that cannot be rendered. I just want to see all the "juicy" characters that the Prime is capable of rendering, and none of the noise viz. I dont want:
[Image: unicode_fun2_noisy.png?raw=1]
I want:
[Image: unicode_fun2.png?raw=1]

I stumbled upon this post about comparing the bitmaps of characters, and managed to write the Prime code to do it. My new character comparison function renders the character as a bitmap, which I then convert into a list of 1' s and 0's and can use this information to compare characters, as rendered.

Code:

EXPORT bit_signature_for_char(c)
BEGIN
  local result={}, x, y, pix;
  TEXTOUT_P(c,G1,0,0,2,#000000,100,#FFFFFF);
  for y from 0 to 5 do  // should probably compare more rows of pixels
    for x from 0 to 100 do
      if GETPIX_P(G1,x, y) = #FFFFFF then
        pix := 0;
      else
        pix := 1;
      end;
      result := concat(result, pix);
    end;
  end;
  return result;
END;

EXPORT same_char(c1, c2)
BEGIN
  return string(bit_signature_for_char(c1)) = string(bit_signature_for_char(c2));
END;

EXPORT UNIFUN()
BEGIN
LOCAL cp, S:="";
PRINT();
FOR cp FROM #2600h TO #26FFh DO
  //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;

Running across a longer range of chars takes time, but gives:
[Image: unicode_fun1.png?raw=1]

A couple of programming issues I ran into:
  • I used the offscreen bitmap G1 but for some reason couldn't use G2 to do the textout renderings of bitmaps?
  • I couldn't find a function to compare lists, so had to convert the lists to strings in order to compare them.
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)