Forum > Windows

[Solved] Defining Unicode Character Constants

(1/3) > >>

ArminLinder:
Hi all,

I programmed a little 3-2-1 countdown. To display encircled numbers I have used the Windows "Wingdings" font, which has encircled numbers 0 .. 9. From the Windows "Character Map" tool I get the character codes $80 ... $89. How do I use these to initialize a string which I can pass to GUI controls to display the characters?

Please see the attachment. As you can see in the screenshot, I did somehow succeed by copying the characters from the Character Map tool via the Windows clipboard. The resulting source code is not very readable. The characters work, but the cryptic string contents seem to drive the Lazarus editor nuts, if I go through the string using the cursor keys the characters are "unsteady", meaning that the string contents changes unexpectedly depending on the cursor position. I am afraid, that the Lazarus IDE has problems too displaying those characters properly, and tehre may be more problems coming, e.g. when using the JEDI code formatter. Better use numbers to initialize them, I think.

Unfortunately, I could not figure out how define character constants this for multi-byte character formats. Shoving the character codes into WideChar or WideString (see commented line below, I passed that to WideString) gives completely different characters in the result string.

Anyone who can help?

Thnks, Armin

Thaddy:
 Since your problem is only with string literals, simply add {$CODEPAGE UTF8} near de top of your program file (lpr)

wp:
I could not find the WingDings font on my system, but found DingBats which contains circled numbers as well. I can confirm that the source editor seems to have issues with cursor placement when such "exotic" UTF-8 characters are used. This is what I do:

* Declare a empty string constant with a describing name for the UTF8 letter, e.g. WHITE_ONE = '';
* Move the cursor in the declaration between the two quotes
* Open the Lazarus character map, search for the UTF-8 page containing the character
* Click on the found character - this copies the character into the editor at the cursor position between the quotes.
* I agree that at this moment only half of the character is displayed in the editor, but once I move the cursor away from the declaration, everything looks correct.
* If it is unpractical to use constants for each character, I try to avoid editing the combined string. It is better to rewrite the string again from the start

marcov:
There is an old open bugreport open for this: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/29071

Back then I was creating test programs for the unicode support of FPC 3.0 :-)

nanobit:

--- Quote from: ArminLinder on January 07, 2024, 08:18:33 pm ---I programmed a little 3-2-1 countdown. To display encircled numbers I have used the Windows "Wingdings" font, which has encircled numbers 0 .. 9. From the Windows "Character Map" tool I get the character codes $80 ... $89. How do I use these to initialize a string which I can pass to GUI controls to display the characters?

--- End quote ---

Wingdings should be avoided, because this is not a Unicode compliant font, but has (charset = SYMBOL_CHARSET).
For example, Wingdings will show character "J" as smiley.

There is a way to use unicode-text functions with WingDings:
via Private Use Area: $F000 + bytecode. But the main problem remains:
The same string will not work with a different font, because Private Use Area glyphs are specific to font.

Navigation

[0] Message Index

[#] Next page

Go to full version