Author Topic: falcon.h and uprint doesn't do extended ASCII characters?  (Read 2980 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
falcon.h and uprint doesn't do extended ASCII characters?
« on: February 19, 2021, 01:52:41 am »
Am I doing something wrong here, or is this just the way uprint is currently set up to work:

Code: QB64: [Select]
  1. DECLARE LIBRARY "falcon"
  2.     SUB uprint_extra (BYVAL x&, BYVAL y&, BYVAL chars%&, BYVAL length%&, BYVAL kern&, BYVAL do_render&, txt_width&, BYVAL charpos%&, charcount&, BYVAL colour~&, BYVAL max_width&)
  3.     FUNCTION uprint (BYVAL x&, BYVAL y&, chars$, BYVAL txt_len&, BYVAL colour~&, BYVAL max_width&)
  4.     FUNCTION uprintwidth (chars$, BYVAL txt_len&, BYVAL max_width&)
  5.     FUNCTION uheight& ()
  6.     FUNCTION uspacing& ()
  7.     FUNCTION uascension& ()
  8.  
  9.  
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. _FONT _LOADFONT("courbd.ttf", 20, "monospace")
  12.  
  13. FOR i = 1 TO 255
  14.     CLS
  15.     r = uprint(0, 0, CHR$(i), 1, -1, 0)
  16.     LOCATE 1, 20: PRINT CHR$(i), i
  17.     SLEEP

None of the ASCII characters below 32, or above 128 print with uprint.  I see Rho has a way to print unicode characters with uprint in his library collection -- do I need to write a routine to convert extended ascii characters to their unicode counterparts, and then print them character by character to have them render properly, or is there some simple trick which I'm missing here?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #1 on: February 19, 2021, 02:19:12 am »
The library very intentionally treats data as UTF-8 strings. You will need to convert non-ascii characters to their equivalent utf8 representation.

I think Rho might have the needed data tables in his falcon wrapper

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #2 on: February 19, 2021, 02:20:17 am »
Even with Rho's conversion to UTF-8 characters, I'm still not getting many of the characters to render properly.  Anyone know what's wrong here.  Tell me I'm doing something simple, wrong.  ;)

Code: QB64: [Select]
  1. DECLARE LIBRARY "falcon"
  2.     SUB uprint_extra (BYVAL x&, BYVAL y&, BYVAL chars%&, BYVAL length%&, BYVAL kern&, BYVAL do_render&, txt_width&, BYVAL charpos%&, charcount&, BYVAL colour~&, BYVAL max_width&)
  3.     FUNCTION uprint (BYVAL x&, BYVAL y&, chars$, BYVAL txt_len&, BYVAL colour~&, BYVAL max_width&)
  4.     FUNCTION uprintwidth (chars$, BYVAL txt_len&, BYVAL max_width&)
  5.     FUNCTION uheight& ()
  6.     FUNCTION uspacing& ()
  7.     FUNCTION uascension& ()
  8.  
  9.  
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. _FONT _LOADFONT("courbd.ttf", 20)
  12.  
  13. FOR i = 1 TO 255
  14.     CLS
  15.     i$ = AnsiTextToUtf8Text(CHR$(i), "PC437")
  16.     UPrintString 0, 0, i$
  17.     LOCATE 1, 20: PRINT CHR$(i), i$, i
  18.     SLEEP
  19.  
  20.  
  21. FUNCTION AnsiTextToUtf8Text$ (text$, cpName$)
  22.     '--- option _explicit requirements ---
  23.     DIM chi&, ascii%, unicode&, aci%
  24.     '--- convert text ---
  25.     AnsiTextToUtf8Text$ = ""
  26.     FOR chi& = 1 TO LEN(text$)
  27.         '--- get ANSI char code, reset Unicode ---
  28.         ascii% = ASC(text$, chi&): unicode& = -1
  29.         IF ascii% > 127 THEN
  30.             '--- convert from which codepage? ---
  31.             SELECT CASE UCASE$(cpName$)
  32.                 CASE "PC437": RESTORE falcon_codepage_data_pc437
  33.                 CASE "PC737": RESTORE falcon_codepage_data_pc737
  34.                 CASE "PC775": RESTORE falcon_codepage_data_pc775
  35.                 CASE "PC850": RESTORE falcon_codepage_data_pc850
  36.                 CASE "PC852": RESTORE falcon_codepage_data_pc852
  37.                 CASE "PC855": RESTORE falcon_codepage_data_pc855
  38.                 CASE "PC857": RESTORE falcon_codepage_data_pc857
  39.                 CASE "PC860": RESTORE falcon_codepage_data_pc860
  40.                 CASE "PC861": RESTORE falcon_codepage_data_pc861
  41.                 CASE "PC862": RESTORE falcon_codepage_data_pc862
  42.                 CASE "PC863": RESTORE falcon_codepage_data_pc863
  43.                 CASE "PC864": RESTORE falcon_codepage_data_pc864
  44.                 CASE "PC865": RESTORE falcon_codepage_data_pc865
  45.                 CASE "PC866": RESTORE falcon_codepage_data_pc866
  46.                 CASE "PCMIK": RESTORE falcon_codepage_data_pcMIK
  47.                 CASE "PC869": RESTORE falcon_codepage_data_pc869
  48.                 CASE "PC874": RESTORE falcon_codepage_data_pc874
  49.                 CASE "WIN1250": RESTORE falcon_codepage_data_win1250
  50.                 CASE "WIN1251": RESTORE falcon_codepage_data_win1251
  51.                 CASE "WIN1252": RESTORE falcon_codepage_data_win1252
  52.                 CASE "WIN1253": RESTORE falcon_codepage_data_win1253
  53.                 CASE "WIN1254": RESTORE falcon_codepage_data_win1254
  54.                 CASE "WIN1255": RESTORE falcon_codepage_data_win1255
  55.                 CASE "WIN1256": RESTORE falcon_codepage_data_win1256
  56.                 CASE "WIN1257": RESTORE falcon_codepage_data_win1257
  57.                 CASE "WIN1258": RESTORE falcon_codepage_data_win1258
  58.                 CASE ELSE: unicode& = _MAPUNICODE(ascii%) 'get Unicode from active codepage
  59.             END SELECT
  60.             '--- or find the Unicode from specified codepage ---
  61.             IF unicode& = -1 THEN
  62.                 FOR aci% = 128 TO ascii%: READ unicode&: NEXT aci%
  63.             END IF
  64.             '--- convert and add UTF-8 char ---
  65.             IF unicode& = 0 THEN unicode& = 65533 'replacement character
  66.             AnsiTextToUtf8Text$ = AnsiTextToUtf8Text$ + UnicodeToUtf8Char$(unicode&)
  67.         ELSE
  68.             '--- standard ASCII (0-127) goes as is ---
  69.             AnsiTextToUtf8Text$ = AnsiTextToUtf8Text$ + CHR$(ascii%)
  70.         END IF
  71.     NEXT chi&
  72.     '-----------------------------
  73.     falcon_codepage_data_pc437:
  74.     DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  75.     DATA 201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402
  76.     DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
  77.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  78.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  79.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  80.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  81.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,32
  82.     falcon_codepage_data_pc737:
  83.     DATA 913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928
  84.     DATA 929,931,932,933,934,935,936,937,945,946,947,948,949,950,951,952
  85.     DATA 953,954,955,956,957,958,959,960,961,963,962,964,965,966,967,968
  86.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  87.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  88.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  89.     DATA 969,940,941,942,970,943,972,973,971,974,902,904,905,906,908,910
  90.     DATA 911,177,8805,8804,938,939,247,8776,176,8729,183,8730,8319,178,9632,160
  91.     falcon_codepage_data_pc775:
  92.     DATA 262,252,233,257,228,291,229,263,322,275,342,343,299,377,196,197
  93.     DATA 201,230,198,333,246,290,162,346,347,214,220,248,163,216,215,164
  94.     DATA 256,298,243,379,380,378,8221,166,169,174,172,189,188,321,171,187
  95.     DATA 9617,9618,9619,9474,9508,260,268,280,278,9571,9553,9559,9565,302,352,9488
  96.     DATA 9492,9524,9516,9500,9472,9532,370,362,9562,9556,9577,9574,9568,9552,9580,381
  97.     DATA 261,269,281,279,303,353,371,363,382,9496,9484,9608,9604,9612,9616,9600
  98.     DATA 211,223,332,323,245,213,181,324,310,311,315,316,326,274,325,8217
  99.     DATA 173,177,8220,190,182,167,247,8222,176,8729,183,185,179,178,9632,160
  100.     falcon_codepage_data_pc850:
  101.     DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  102.     DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402
  103.     DATA 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
  104.     DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  105.     DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  106.     DATA 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
  107.     DATA 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
  108.     DATA 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
  109.     falcon_codepage_data_pc852:
  110.     DATA 199,252,233,226,228,367,263,231,322,235,336,337,238,377,196,262
  111.     DATA 201,313,314,244,246,317,318,346,347,214,220,356,357,321,215,269
  112.     DATA 225,237,243,250,260,261,381,382,280,281,172,378,268,351,171,187
  113.     DATA 9617,9618,9619,9474,9508,193,194,282,350,9571,9553,9559,9565,379,380,9488
  114.     DATA 9492,9524,9516,9500,9472,9532,258,259,9562,9556,9577,9574,9568,9552,9580,164
  115.     DATA 273,272,270,203,271,327,205,206,283,9496,9484,9608,9604,354,366,9600
  116.     DATA 211,223,212,323,324,328,352,353,340,218,341,368,253,221,355,180
  117.     DATA 173,733,731,711,728,167,247,184,176,168,729,369,344,345,9632,160
  118.     falcon_codepage_data_pc855:
  119.     DATA 1106,1026,1107,1027,1105,1025,1108,1028,1109,1029,1110,1030,1111,1031,1112,1032
  120.     DATA 1113,1033,1114,1034,1115,1035,1116,1036,1118,1038,1119,1039,1102,1070,1098,1066
  121.     DATA 1072,1040,1073,1041,1094,1062,1076,1044,1077,1045,1092,1060,1075,1043,171,187
  122.     DATA 9617,9618,9619,9474,9508,1093,1061,1080,1048,9571,9553,9559,9565,1081,1049,9488
  123.     DATA 9492,9524,9516,9500,9472,9532,1082,1050,9562,9556,9577,9574,9568,9552,9580,164
  124.     DATA 1083,1051,1084,1052,1085,1053,1086,1054,1087,9496,9484,9608,9604,1055,1103,9600
  125.     DATA 1071,1088,1056,1089,1057,1090,1058,1091,1059,1078,1046,1074,1042,1100,1068,8470
  126.     DATA 173,1099,1067,1079,1047,1096,1064,1101,1069,1097,1065,1095,1063,167,9632,160
  127.     falcon_codepage_data_pc857:
  128.     DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,305,196,197
  129.     DATA 201,230,198,244,246,242,251,249,304,214,220,248,163,216,350,351
  130.     DATA 225,237,243,250,241,209,286,287,191,174,172,189,188,161,171,187
  131.     DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  132.     DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  133.     DATA 186,170,202,203,200,0,205,206,207,9496,9484,9608,9604,166,204,9600
  134.     DATA 211,223,212,210,245,213,181,0,215,218,219,217,236,255,175,180
  135.     DATA 173,177,0,190,182,167,247,184,176,168,183,185,179,178,9632,160
  136.     falcon_codepage_data_pc860:
  137.     DATA 199,252,233,226,227,224,193,231,234,202,232,205,212,236,195,194
  138.     DATA 201,192,200,244,245,242,218,249,204,213,220,162,163,217,8359,211
  139.     DATA 225,237,243,250,241,209,170,186,191,210,172,189,188,161,171,187
  140.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  141.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  142.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  143.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  144.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  145.     falcon_codepage_data_pc861:
  146.     DATA 199,252,233,226,228,224,229,231,234,235,232,208,240,222,196,197
  147.     DATA 201,230,198,244,246,254,251,221,253,214,220,248,163,216,8359,402
  148.     DATA 225,237,243,250,193,205,211,218,191,8976,172,189,188,161,171,187
  149.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  150.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  151.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  152.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  153.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  154.     falcon_codepage_data_pc862:
  155.     DATA 1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503
  156.     DATA 1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,162,163,165,8359,402
  157.     DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
  158.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  159.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  160.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  161.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  162.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  163.     falcon_codepage_data_pc863:
  164.     DATA 199,252,233,226,194,224,182,231,234,235,232,239,238,8215,192,167
  165.     DATA 201,200,202,244,203,207,251,249,164,212,220,162,163,217,219,402
  166.     DATA 166,180,243,250,168,184,179,175,206,8976,172,189,188,190,171,187
  167.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  168.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  169.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  170.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  171.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  172.     falcon_codepage_data_pc864:
  173.     DATA 176,183,8729,8730,9618,9472,9474,9532,9508,9516,9500,9524,9488,9484,9492,9496
  174.     DATA 946,8734,966,177,189,188,8776,171,187,65271,65272,0,0,65275,65276,0
  175.     DATA 160,173,65154,163,164,65156,0,0,65166,65167,65173,65177,1548,65181,65185,65189
  176.     DATA 1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,65233,1563,65201,65205,65209,1567
  177.     DATA 162,65152,65153,65155,65157,65226,65163,65165,65169,65171,65175,65179,65183,65187,65191,65193
  178.     DATA 65195,65197,65199,65203,65207,65211,65215,65217,65221,65227,65231,166,172,247,215,65225
  179.     DATA 1600,65235,65239,65243,65247,65251,65255,65259,65261,65263,65267,65213,65228,65230,65229,65249
  180.     DATA 65149,1617,65253,65257,65260,65264,65266,65232,65237,65269,65270,65245,65241,65265,9632,0
  181.     falcon_codepage_data_pc865:
  182.     DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  183.     DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,8359,402
  184.     DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,164
  185.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  186.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  187.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  188.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  189.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  190.     falcon_codepage_data_pc866:
  191.     DATA 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055
  192.     DATA 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071
  193.     DATA 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087
  194.     DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  195.     DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  196.     DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  197.     DATA 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103
  198.     DATA 1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160
  199.     falcon_codepage_data_pcMIK:
  200.     DATA 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055
  201.     DATA 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071
  202.     DATA 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087
  203.     DATA 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103
  204.     DATA 9492,9524,9516,9500,9472,9532,9571,9553,9562,9566,9577,9574,9568,9552,9580,9488
  205.     DATA 9617,9618,9619,9474,9508,8470,167,9559,9565,9496,9484,9608,9604,9612,9616,9600
  206.     DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  207.     DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  208.     falcon_codepage_data_pc869:
  209.     DATA 0,0,0,0,0,0,902,0,183,172,166,8216,8217,904,8213,905
  210.     DATA 906,938,908,0,0,910,939,169,911,178,179,940,163,941,942,943
  211.     DATA 970,912,972,973,913,914,915,916,917,918,919,189,920,921,171,187
  212.     DATA 9617,9618,9619,9474,9508,922,923,924,925,9571,9553,9559,9565,926,927,9488
  213.     DATA 9492,9524,9516,9500,9472,9532,928,929,9562,9556,9577,9574,9568,9552,9580,931
  214.     DATA 932,933,934,935,936,937,945,946,947,9496,9484,9608,9604,948,949,9600
  215.     DATA 950,951,952,953,954,955,956,957,958,959,960,961,963,962,964,900
  216.     DATA 173,177,965,966,967,167,968,901,176,168,969,971,944,974,9632,160
  217.     falcon_codepage_data_pc874:
  218.     DATA 8364,0,0,0,0,8230,0,0,0,0,0,0,0,0,0,0
  219.     DATA 0,8216,8217,8220,8221,8226,8211,8212,0,0,0,0,0,0,0,0
  220.     DATA 160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599
  221.     DATA 3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615
  222.     DATA 3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631
  223.     DATA 3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,0,0,0,0,3647
  224.     DATA 3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663
  225.     DATA 3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,0,0,0,0
  226.     falcon_codepage_data_win1250:
  227.     DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,352,8249,346,356,381,377
  228.     DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,353,8250,347,357,382,378
  229.     DATA 160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379
  230.     DATA 176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380
  231.     DATA 340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270
  232.     DATA 272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223
  233.     DATA 341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271
  234.     DATA 273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729
  235.     falcon_codepage_data_win1251:
  236.     DATA 1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039
  237.     DATA 1106,8216,8217,8220,8221,8226,8211,8212,0,8482,1113,8250,1114,1116,1115,1119
  238.     DATA 160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031
  239.     DATA 176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111
  240.     DATA 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055
  241.     DATA 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071
  242.     DATA 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087
  243.     DATA 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103
  244.     falcon_codepage_data_win1252:
  245.     DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
  246.     DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
  247.     DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  248.     DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  249.     DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  250.     DATA 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
  251.     DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  252.     DATA 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  253.     falcon_codepage_data_win1253:
  254.     DATA 8364,0,8218,402,8222,8230,8224,8225,0,8240,0,8249,0,0,0,0
  255.     DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,0,8250,0,0,0,0
  256.     DATA 160,901,902,163,164,165,166,167,168,169,0,171,172,173,174,8213
  257.     DATA 176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911
  258.     DATA 912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927
  259.     DATA 928,929,0,931,932,933,934,935,936,937,938,939,940,941,942,943
  260.     DATA 944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959
  261.     DATA 960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,0
  262.     falcon_codepage_data_win1254:
  263.     DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,0,0
  264.     DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,0,376
  265.     DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  266.     DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  267.     DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  268.     DATA 286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223
  269.     DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  270.     DATA 287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255
  271.     falcon_codepage_data_win1255:
  272.     DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,0,8249,0,0,0,0
  273.     DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,0,8250,0,0,0,0
  274.     DATA 160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175
  275.     DATA 176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191
  276.     DATA 1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,0,1467,1468,1469,1470,1471
  277.     DATA 1472,1473,1474,1475,1520,1521,1522,1523,1524,0,0,0,0,0,0,0
  278.     DATA 1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503
  279.     DATA 1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,0,0,8206,8207,0
  280.     falcon_codepage_data_win1256:
  281.     DATA 8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672
  282.     DATA 1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722
  283.     DATA 160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175
  284.     DATA 176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567
  285.     DATA 1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583
  286.     DATA 1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603
  287.     DATA 224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239
  288.     DATA 1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746
  289.     falcon_codepage_data_win1257:
  290.     DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,0,8249,0,168,711,184
  291.     DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,0,8250,0,175,731,0
  292.     DATA 160,0,162,163,164,0,166,167,216,169,342,171,172,173,174,198
  293.     DATA 176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230
  294.     DATA 260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315
  295.     DATA 352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223
  296.     DATA 261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316
  297.     DATA 353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729
  298.     falcon_codepage_data_win1258:
  299.     DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,0,8249,338,0,0,0
  300.     DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,0,8250,339,0,0,376
  301.     DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  302.     DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  303.     DATA 192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207
  304.     DATA 272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223
  305.     DATA 224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239
  306.     DATA 273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255
  307.  
  308. SUB UPrintString (xPos%, yPos%, utf8text$)
  309.     '--- tracking ---
  310.     REDIM falcon_charpos_array&(0 TO LEN(utf8text$))
  311.     uprint_extra 0, 0, _OFFSET(utf8text$), LEN(utf8text$), -1, 0, falcon_current_printwidth&, _OFFSET(falcon_charpos_array&()), falcon_charpos_count&, 0, 0
  312.     '--- printing ---
  313.     falcon_printmode_emulation xPos%, yPos%, utf8text$
  314.  
  315. '--- undocumented - for internal use only
  316. '---------------------------------------------------------------------
  317. SUB falcon_printmode_emulation (xPos%, yPos%, utf8text$)
  318.     '--- option _explicit requirements ---
  319.     DIM xs%, xw%, ys%, ulc~&, amImg&, bgr%, bgg%, bgb%, bga%, amOff%&, x%, y%, amv~&, cmv~&
  320.     '--- print according to active mode ---
  321.     IF LEN(utf8text$) = 0 THEN
  322.         falcon_charpos_array&(0) = 0: falcon_charpos_count& = 0
  323.         falcon_current_printwidth& = 0
  324.     ELSE
  325.         SELECT CASE _PRINTMODE
  326.             CASE 1, 3
  327.                 '--- _KEEPBACKGROUND, _FILLBACKGROUND ---
  328.                 IF _PRINTMODE = 3 THEN LINE (xPos%, yPos%)-STEP(falcon_current_printwidth& - 1, UPrintHeight% - 1), _BACKGROUNDCOLOR, BF
  329.                 uprint_extra xPos%, yPos%, _OFFSET(utf8text$), LEN(utf8text$), -1, -1, falcon_current_printwidth&, _OFFSET(falcon_charpos_array&()), falcon_charpos_count&, _DEFAULTCOLOR, falcon_current_printwidth&
  330.                 IF falcon_underline_mode% <> 0 AND falcon_current_printwidth& > 0 THEN
  331.                     IF falcon_underline_first% <= falcon_charpos_count& THEN
  332.                         xs% = xPos% + falcon_charpos_array&(falcon_underline_first% - 1)
  333.                         IF falcon_underline_last% > 0 AND falcon_underline_last% < falcon_charpos_count& THEN
  334.                             xw% = falcon_charpos_array&(falcon_underline_last%) - falcon_charpos_array&(falcon_underline_first% - 1)
  335.                         ELSE
  336.                             xw% = falcon_charpos_array&(falcon_charpos_count&) - falcon_charpos_array&(falcon_underline_first% - 1)
  337.                         END IF
  338.                         ys% = yPos% + uascension& + falcon_underline_offset%
  339.                         IF falcon_underline_mode% < 0 THEN ulc~& = _DEFAULTCOLOR: ELSE ulc~& = falcon_underline_color~&
  340.                         LINE (xs%, ys%)-STEP(xw% - 1, falcon_underline_thickness% - 1), ulc~&, BF
  341.                     END IF
  342.                 END IF
  343.             CASE 2
  344.                 '--- _ONLYBACKGROUND ---
  345.                 '--- temporary B&W print to get a proper gray blend mask ---
  346.                 amImg& = _NEWIMAGE(falcon_current_printwidth&, UPrintHeight%, 32)
  347.                 _DEST amImg&: _FONT _FONT(0): CLS , &HFFFFFFFF
  348.                 uprint_extra 0, 0, _OFFSET(utf8text$), LEN(utf8text$), -1, -1, falcon_current_printwidth&, _OFFSET(falcon_charpos_array&()), falcon_charpos_count&, &HFF000000, falcon_current_printwidth&
  349.                 IF falcon_underline_mode% <> 0 AND falcon_current_printwidth& > 0 THEN
  350.                     IF falcon_underline_first% <= falcon_charpos_count& THEN
  351.                         xs% = falcon_charpos_array&(falcon_underline_first% - 1)
  352.                         IF falcon_underline_last% > 0 AND falcon_underline_last% < falcon_charpos_count& THEN
  353.                             xw% = falcon_charpos_array&(falcon_underline_last%) - falcon_charpos_array&(falcon_underline_first% - 1)
  354.                         ELSE
  355.                             xw% = falcon_charpos_array&(falcon_charpos_count&) - falcon_charpos_array&(falcon_underline_first% - 1)
  356.                         END IF
  357.                         ys% = uascension& + falcon_underline_offset%
  358.                         IF falcon_underline_mode% < 0 THEN ulc~& = _DEFAULTCOLOR: ELSE ulc~& = falcon_underline_color~&
  359.                         LINE (xs%, ys%)-STEP(xw% - 1, falcon_underline_thickness% - 1), &HFF000000, BF
  360.                     END IF
  361.                 END IF
  362.                 _DEST 0
  363.                 '--- colorize the mask with active background ---
  364.                 '--- and transpose the gray level into alpha ---
  365.                 bgr% = _RED32(_BACKGROUNDCOLOR): bgg% = _GREEN32(_BACKGROUNDCOLOR)
  366.                 bgb% = _BLUE32(_BACKGROUNDCOLOR): bga% = _ALPHA32(_BACKGROUNDCOLOR)
  367.                 $CHECKING:OFF
  368.                 DIM amBuf AS _MEM: amBuf = _MEMIMAGE(amImg&)
  369.                 amOff%& = amBuf.OFFSET
  370.                 FOR x% = 0 TO falcon_current_printwidth& - 1
  371.                     FOR y% = 0 TO UPrintHeight% - 1
  372.                         _MEMGET amBuf, amOff%&, amv~&
  373.                         cmv~& = _RGBA32(bgr%, bgg%, bgb%, _RED32(amv~&) / 255 * bga%)
  374.                         _MEMPUT amBuf, amOff%&, cmv~& '     ^^-- R,G or B doesn't matter,
  375.                         amOff%& = amOff%& + 4 '                  as it's a gray level
  376.                     NEXT y%
  377.                 NEXT x%
  378.                 _MEMFREE amBuf
  379.                 $CHECKING:ON
  380.                 '--- print image & cleanup ---
  381.                 _PUTIMAGE (xPos%, yPos%), amImg&
  382.                 _FREEIMAGE amImg&
  383.         END SELECT
  384.     END IF
  385.     falcon_recommended_next_x% = xPos% + falcon_current_printwidth&
  386.     falcon_recommended_next_y% = yPos% + UPrintHeight%
  387.     IF xPos% < falcon_box_start_x% THEN falcon_box_start_x% = xPos%
  388.     IF yPos% < falcon_box_start_y% THEN falcon_box_start_y% = yPos%
  389.     IF falcon_recommended_next_x% > falcon_box_end_x% THEN falcon_box_end_x% = falcon_recommended_next_x%
  390.     IF falcon_recommended_next_y% > falcon_box_end_y% THEN falcon_box_end_y% = falcon_recommended_next_y%
  391.  
  392. FUNCTION GetAnsiCodepage$
  393.     '--- option _explicit requirements ---
  394.     DIM sum&, ascii%, unicode&
  395.     '--- identify codepage ---
  396.     'First do a quick codepage check by just summing up all unicodes of the
  397.     'shortest char sequence which is unique across all supported codepages.
  398.     'This is a sequence of 23 chars starting at ASCII code 154.
  399.     sum& = 0
  400.     FOR ascii% = 154 TO 176
  401.         sum& = sum& + _MAPUNICODE(ascii%)
  402.     NEXT ascii%
  403.     SELECT CASE sum&
  404.         CASE 31084: GetAnsiCodepage$ = "Pc437": RESTORE falcon_codepage_data_pc437
  405.         CASE 30682: GetAnsiCodepage$ = "Pc737": RESTORE falcon_codepage_data_pc737
  406.         CASE 22735: GetAnsiCodepage$ = "Pc775": RESTORE falcon_codepage_data_pc775
  407.         CASE 14275: GetAnsiCodepage$ = "Pc850": RESTORE falcon_codepage_data_pc850
  408.         CASE 15682: GetAnsiCodepage$ = "Pc852": RESTORE falcon_codepage_data_pc852
  409.         CASE 31363: GetAnsiCodepage$ = "Pc855": RESTORE falcon_codepage_data_pc855
  410.         CASE 14576: GetAnsiCodepage$ = "Pc857": RESTORE falcon_codepage_data_pc857
  411.         CASE 22179: GetAnsiCodepage$ = "Pc860": RESTORE falcon_codepage_data_pc860
  412.         CASE 31242: GetAnsiCodepage$ = "Pc861": RESTORE falcon_codepage_data_pc861
  413.         CASE 32378: GetAnsiCodepage$ = "Pc862": RESTORE falcon_codepage_data_pc862
  414.         CASE 22824: GetAnsiCodepage$ = "Pc863": RESTORE falcon_codepage_data_pc863
  415.         CASE 786211: GetAnsiCodepage$ = "Pc864": RESTORE falcon_codepage_data_pc864
  416.         CASE 31198: GetAnsiCodepage$ = "Pc865": RESTORE falcon_codepage_data_pc865
  417.         CASE 33300: GetAnsiCodepage$ = "Pc866": RESTORE falcon_codepage_data_pc866
  418.         CASE 24771: GetAnsiCodepage$ = "PcMIK": RESTORE falcon_codepage_data_pcMIK
  419.         CASE 26352: GetAnsiCodepage$ = "Pc869": RESTORE falcon_codepage_data_pc869
  420.         CASE 57640: GetAnsiCodepage$ = "Pc874": RESTORE falcon_codepage_data_pc874
  421.         CASE 14676: GetAnsiCodepage$ = "Win1250": RESTORE falcon_codepage_data_win1250
  422.         CASE 22959: GetAnsiCodepage$ = "Win1251": RESTORE falcon_codepage_data_win1251
  423.         CASE 12556: GetAnsiCodepage$ = "Win1252": RESTORE falcon_codepage_data_win1252
  424.         CASE 20454: GetAnsiCodepage$ = "Win1253": RESTORE falcon_codepage_data_win1253
  425.         CASE 12174: GetAnsiCodepage$ = "Win1254": RESTORE falcon_codepage_data_win1254
  426.         CASE 19349: GetAnsiCodepage$ = "Win1255": RESTORE falcon_codepage_data_win1255
  427.         CASE 34200: GetAnsiCodepage$ = "Win1256": RESTORE falcon_codepage_data_win1256
  428.         CASE 11929: GetAnsiCodepage$ = "Win1257": RESTORE falcon_codepage_data_win1257
  429.         CASE 11821: GetAnsiCodepage$ = "Win1258": RESTORE falcon_codepage_data_win1258
  430.         CASE ELSE: GetAnsiCodepage$ = "custom"
  431.     END SELECT
  432.     'If codepage is identified, then check if it's still in standard
  433.     'mapping or maybe modified by the user.
  434.     IF GetAnsiCodepage$ <> "custom" THEN
  435.         FOR ascii% = 128 TO 255
  436.             READ unicode&
  437.             IF _MAPUNICODE(ascii%) <> unicode& THEN
  438.                 GetAnsiCodepage$ = "custom"
  439.                 EXIT FOR
  440.             END IF
  441.         NEXT ascii%
  442.     END IF
  443.  
  444. FUNCTION UnicodeToUtf8Char$ (unicode&)
  445.     '--- option _explicit requirements ---
  446.     DIM uc&, first%, remain%, conti%
  447.     '--- UTF-8 encoding ---
  448.     IF unicode& < 128 THEN
  449.         '--- standard ASCII (0-127) goes as is ---
  450.         UnicodeToUtf8Char$ = CHR$(unicode&)
  451.         EXIT FUNCTION
  452.     ELSE
  453.         '--- encode the Unicode into UTF-8 notation ---
  454.         UnicodeToUtf8Char$ = "": uc& = unicode& 'avoid argument side effect
  455.         first% = &B10000000: remain% = 63
  456.         DO
  457.             first% = &B10000000 OR (first% \ 2): remain% = (remain% \ 2)
  458.             conti% = &B10000000 OR (uc& AND &B00111111): uc& = uc& \ 64
  459.             UnicodeToUtf8Char$ = CHR$(conti%) + UnicodeToUtf8Char$
  460.             IF uc& <= remain% THEN
  461.                 first% = (first% OR uc&): uc& = 0
  462.             END IF
  463.         LOOP UNTIL uc& = 0
  464.         UnicodeToUtf8Char$ = CHR$(first%) + UnicodeToUtf8Char$
  465.     END IF
  466.  

And my apologies to @RhoSigma, as I've hacked the heck out of his code to test and paste the relevant portions of it into my own zombified test here.  I was trying to grab and examine only what I needed to get utf-8 characters to print, but  it seems even with all this, I'm still not getting many to display properly.

Does this require an unicode font, like cyberbit.ttf?  Does it work at all?  Or am I just doing something wrong here?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #3 on: February 19, 2021, 03:34:57 am »
Not sure what you're looking for, but running the code from your latest post it works all as expected to me. Ok, you just get the square for ASCII 0-31 and 127, but that's a matter of falcon.h, where those control chars are substituted with the square replacement character. If you want those, then you have to go into falcon.h and tweak it there.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #4 on: February 19, 2021, 04:20:22 am »
Some of the other characters are coming back blank for me; in the upper 180+ ranges.  It’s late tonight, but I can get you a list of all the non-characters tomorrow, if you want.  CHR$(240) is one I was trying to use earlier, but it doesn’t render at all, no matter what I try with it, so far.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #5 on: February 19, 2021, 05:10:57 am »
No problem here. All that chars showing up. Probably really differences in  the TTF font files from system to system, as you suggested the other day.
« Last Edit: February 19, 2021, 05:16:36 pm by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #6 on: February 19, 2021, 01:11:15 pm »
I finally got it all sorted out, I think.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 720, 32)
  2. _FONT _LOADFONT("courbd.ttf", 20, "monospace")
  3.  
  4. FOR y = 0 TO 15
  5.     FOR x = 0 TO 15
  6.         QPrintString x * 20, y * uheight, CHR$(count)
  7.         count = count + 1
  8.     NEXT
  9.  
  10. SUB QPrint (temp$)
  11.     $IF FALCON = UNDEFINED THEN
  12.         $LET FALCON = TRUE
  13.         DECLARE LIBRARY "falcon"
  14.             SUB uprint_extra (BYVAL x&, BYVAL y&, BYVAL chars%&, BYVAL length%&, BYVAL kern&, BYVAL do_render&, txt_width&, BYVAL charpos%&, charcount&, BYVAL colour~&, BYVAL max_width&)
  15.             FUNCTION uprint (BYVAL x&, BYVAL y&, chars$, BYVAL txt_len&, BYVAL colour~&, BYVAL max_width&)
  16.             FUNCTION uprintwidth (chars$, BYVAL txt_len&, BYVAL max_width&)
  17.             FUNCTION uheight& ()
  18.             FUNCTION uspacing& ()
  19.             FUNCTION uascension& ()
  20.         END DECLARE
  21.     $END IF
  22.     STATIC m AS _MEM: m = _MEMIMAGE(0)
  23.     DIM BreakPoint AS STRING
  24.     BreakPoint = ",./- ;:!" 'I consider all these to be valid breakpoints.  If you want something else, change them.
  25.     text$ = _TRIM$(AnsiTextToUtf8Text$(temp$))
  26.     count = -1
  27.     DO
  28.         'first find the natural length of the line
  29.         x = POS(0): IF _FONTWIDTH THEN x = x * _FONTWIDTH
  30.         y = CSRLIN
  31.         wide% = _WIDTH - x - 1
  32.         FOR i = 1 TO LEN(text$)
  33.             IF ASC(text$, i) = 10 OR ASC(text$, i) = 13 THEN i = i - 1: EXIT FOR
  34.             p = uprintwidth(text$, i, 0)
  35.             IF p > wide% THEN EXIT FOR
  36.         NEXT
  37.         'IF i < LEN(text$) THEN lineend = i - 1 ELSE
  38.         lineend = i
  39.  
  40.         t$ = RTRIM$(LEFT$(text$, lineend)) 'at most, our line can't be any longer than what fits the screen.
  41.         FOR i = lineend TO 1 STEP -1
  42.             IF INSTR(BreakPoint, MID$(text$, i, 1)) THEN lineend = i: EXIT FOR
  43.         NEXT
  44.         out$ = RTRIM$(LEFT$(text$, lineend))
  45.         text$ = LTRIM$(MID$(text$, lineend + 1))
  46.         IF LEFT$(text$, 2) = CHR$(13) + CHR$(10) THEN text$ = MID$(text$, 3)
  47.         IF LEFT$(text$, 2) = CHR$(10) + CHR$(13) THEN text$ = MID$(text$, 3)
  48.         IF LEFT$(text$, 1) = CHR$(13) THEN text$ = MID$(text$, 2)
  49.         IF LEFT$(text$, 1) = CHR$(10) THEN text$ = MID$(text$, 2)
  50.         IF _BACKGROUNDCOLOR <> 0 THEN
  51.             LINE (x - 1, (y - 1) * uheight)-STEP(uprintwidth(out$, LEN(out$), 0), uheight), _BACKGROUNDCOLOR, BF
  52.         END IF
  53.         w& = uprint(x - 1, (y - 1) * uheight, out$, LEN(out$), _DEFAULTCOLOR, 0)
  54.         x = 1
  55.         IF y + 1 >= _HEIGHT / uheight THEN 'scroll up
  56.             h = uheight * _WIDTH * 4
  57.             t$ = SPACE$(m.SIZE - h)
  58.             _MEMGET m, m.OFFSET + h, t$
  59.             CLS , 0
  60.             _MEMPUT m, m.OFFSET, t$
  61.             LOCATE y, x
  62.         ELSE
  63.             LOCATE y + 1, x
  64.         END IF
  65.  
  66.     LOOP UNTIL text$ = ""
  67.     clean_exit:
  68.  
  69. FUNCTION QPrintWidth& (out$)
  70.     QPrintWidth = uprintwidth(out$, LEN(out$), 0)
  71.  
  72. FUNCTION QFontHeight
  73.     QFontHeight = uheight
  74.  
  75. SUB QPrintString (x, y, text$)
  76.     $IF FALCON = UNDEFINED THEN
  77.         $LET FALCON = TRUE
  78.         DECLARE LIBRARY "falcon"
  79.         SUB uprint_extra (BYVAL x&, BYVAL y&, BYVAL chars%&, BYVAL length%&, BYVAL kern&, BYVAL do_render&, txt_width&, BYVAL charpos%&, charcount&, BYVAL colour~&, BYVAL max_width&)
  80.         FUNCTION uprint (BYVAL x&, BYVAL y&, chars$, BYVAL txt_len&, BYVAL colour~&, BYVAL max_width&)
  81.         FUNCTION uprintwidth (chars$, BYVAL txt_len&, BYVAL max_width&)
  82.         FUNCTION uheight& ()
  83.         FUNCTION uspacing& ()
  84.         FUNCTION uascension& ()
  85.         END DECLARE
  86.     $END IF
  87.     temp$ = AnsiTextToUtf8Text$(text$)
  88.         LINE (x, y)-STEP(uprintwidth(temp$, LEN(temp$), 0), uheight), _BACKGROUNDCOLOR, BF
  89.     END IF
  90.     w& = uprint(x, y, temp$, LEN(temp$), _DEFAULTCOLOR, 0)
  91.  
  92. FUNCTION AnsiTextToUtf8Text$ (text$)
  93.     DIM chi&, ascii%, unicode&, aci%
  94.     FOR chi& = 1 TO LEN(text$)
  95.         unicode& = _MAPUNICODE(ASC(text$, chi&))
  96.         IF unicode& = 0 THEN unicode& = 65533 'replacement character
  97.         AnsiTextToUtf8Text$ = AnsiTextToUtf8Text$ + UnicodeToUtf8Char$(unicode&)
  98.     NEXT chi&
  99.  
  100. FUNCTION UnicodeToUtf8Char$ (unicode&)
  101.     '--- option _explicit requirements ---
  102.     DIM uc&, first%, remain%, conti%
  103.     '--- UTF-8 encoding ---
  104.     IF unicode& < 128 THEN
  105.         '--- standard ASCII (0-127) goes as is ---
  106.         UnicodeToUtf8Char$ = CHR$(unicode&)
  107.         EXIT FUNCTION
  108.     ELSE
  109.         '--- encode the Unicode into UTF-8 notation ---
  110.         UnicodeToUtf8Char$ = "": uc& = unicode& 'avoid argument side effect
  111.         first% = &B10000000: remain% = 63
  112.         DO
  113.             first% = &B10000000 OR (first% \ 2): remain% = (remain% \ 2)
  114.             conti% = &B10000000 OR (uc& AND &B00111111): uc& = uc& \ 64
  115.             UnicodeToUtf8Char$ = CHR$(conti%) + UnicodeToUtf8Char$
  116.             IF uc& <= remain% THEN
  117.                 first% = (first% OR uc&): uc& = 0
  118.             END IF
  119.         LOOP UNTIL uc& = 0
  120.         UnicodeToUtf8Char$ = CHR$(first%) + UnicodeToUtf8Char$
  121.     END IF
  122.  

This is now giving me the whole character page with characters from CHR$(0) to CHR$(255).  I had an UTF8toUnicode function which I'd written before, but it generated an aray of up to 4bytes for my needs, and rather than work on converting it, I simply stole your's Rho -- if that's okay with you?  ;)

  [ You are not allowed to view this attachment ]  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: falcon.h and uprint doesn't do extended ASCII characters?
« Reply #7 on: February 19, 2021, 01:34:49 pm »
... rather than work on converting it, I simply stole your's Rho -- if that's okay with you?  ;)

If it helps to get your things done, then just go ahead. That's why we're here, to share ideas and code of course.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack