Forum > Windows

[Solved] Defining Unicode Character Constants

<< < (2/3) > >>

ArminLinder:
Thanks, guys, Thaddy and Nanobit did it - together. What I actually had to do is:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+}{$CODEPAGE UTF8} interface  ... const  FontName1 = 'Courier';  FontName2 = 'Wingdings';  // TestText  = '€‚ƒ„…†‡ˆ‰';  TestText1  = 'äöüÄÖÜßabcdef';  TestText2  = #$F080#$F081#$F082#$F083#$F084#$F085#$F086#$F087#$F088#$F089; ...  
... and with some more small modifications in the onClick handlers (Button 1 display TestText1 in "Courier", Button2 display Texttext 2 in "Windings" I get a perfect result.

Doing either $CODEPAGE or $F0.. did not help, I needed to do both.

Thanks a lot!

Armin.

ArminLinder:
Probably someone else reaches here, and may find these findings helpful.

Looking deeper into the whole typographic mess I came to a point where I found, as Nanobit was pointing out, that "Windings" does indeed not support Unicode character mappings, but is a leftover from the pre-Unicode era adhering to Microsofts proprietary "Windows" ("ANSI?") standard.

If so, why then do the characters display properly, if I use $codepage UTF-8, and btw, isn't UTF-8 a character encoding scheme and not a character mapping table (codepage)? I assumed, that $codepage UTF-8 could be a naming mispick, meaning "expect character literals to be specified using UTF-8 encoding", having nothing to do with codepages.

This would not explain, however, why the encircled numbers symbols do magically appear in the Unicode "Private Use Area", which is reserved for "user-specific" font customizations. What technology maps character faces taken from the Windings font into the "PUA"? And how can one know which characters are contained in the PUA?

I found this document: https://scripts.sil.org/cms/scripts/page.php?id=VendorUseOfPUA&site_id=nrsi#14086407

which explains: it is a customization Microsoft has made to make Windows/ANSI symbol fonts (which do not at all map to any Unicode codepage) accessible via Unicode strings. Windings is not a Unicode font, so the Unicode PUA contained in the Unicode "Basic" plane (code $00), is exploited. The first byte of the actual character code is therefore $00. $F0 is the code of the PUA where Microsoft has choosen to start the mapping, so the second byte is $F0. From there the codes follow the offset the character had in the original Windows/ANSI table, which is, for the encircled zero symbol, $80 as displayed by the Windows character map tool.

The complete code for character "encircled 0" is therefore $00$F0$80, or, simplified, $F080, the constant given by Nanobit.

For comparison: according to Unicode specs the encircled numbers are found from codepoint U+$24F5 / $E2$91$A0, for fonts which are natively "Unicode" compliant. There is no guarantee, however that a Unicode-compliant font must contain all of the zillions of characters Unicode supports, and browsing the fonts my Windows 11 has built-in I found no font which supports the encircled characters natively, but my search was quite superficial. I could have missed one.

A built-in cross-platform font would definitely be my favourite pick, if there was one. There are lists of cross-platform founts available (e.g. https://en.wikipedia.org/wiki/Open-source_Unicode_typefaces) but none of these seems to be included in any Windows distribution, and I am reluctant to force my end-users to mess with font distribution. So I go with Microsofts workaround for the moment, the program is not intended to work outside the Windows world.

What a mess, mission finally accomplished for just one character, sacrificing cross-platform, and there are thousands more. Tools to come to the rescue? Neither the Windows Character Map nor Lazarus built-in "insert character" facility was of much help with this issue. It took me some time to finally find a tool which is able to display the whole thing: BabelMap (https://www.babelstone.co.uk/Software/Download). See screenshot below.

Mission completed. May this save someone some time in the future.

Armin.

Thaddy:
The wingdings font was created for, ahum, Windows 1! (although not yet as truetype font format. That came with Windows 3.1)
With it you are able to create GUI like interfaces that are actually still plain DOS... I played a lot with it, back in the days, although I never had Windows 1.
See the screenshot, that GUI like interface is completely done with wingdings.
You can also see wingdings is a monospace font.
Also note such interfaces are severely code page restricted to cp850/cp427.
But there is a rudimentary canvas.

Thaddy:

--- Quote from: ArminLinder on January 11, 2024, 02:12:15 pm ---Thanks, guys, Thaddy and Nanobit did it - together. What I actually had to do is:

--- End quote ---
No, you should have declared the consts as typed consts.

ArminLinder:
Thaddy,

Better?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  FontName1 = 'Courier';  FontName2 = 'Wingdings';  TestText1  = 'äöüÄÖÜßabcdef';  TestText2 : UnicodeString = #$F080#$F081#$F082#$F083#$F084#$F085#$F086#$F087#$F088#$F089; 
If yes, ok, as I see it, just writing the constant as I did leaves it to FPC what kind of actual string type it assumes. Depending on compiler switches it may be Unicode or something else.

I have my reasons why I usually don't write typed string constants, but that's a discussion for another day.

Regarding the screenshot ... wow, I thought I had seen all Windows desktops right from the beginning ... what GUI has THAT been? I saw those line-style icons for the system menu before, but was it indeed in Windows? Looks a bit like a text-shell of some kind?

[Edit: it was actually Windows 1.x, which didn't make it across the ocean in that days, at least not onto my desk :-) My Windows life began with Windows 3.x, and till now I thought that Windows 3.0 had actually been the first version.]

Armin.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version