I'm struggling to get the euro sign in a label or on a button in GtkAda.
I have the euro sign on my German keyboard (on the E key), but I have no idea how this is encoded. So how do I get this in UTF8?
Is there no way to use the character € directly? Imagine, you want to write cyrillc on label of a gui? Would you use hex values or would you write
Я говорю по-русски.
custom widget from Gtk_Grid_Record. Then I call Initialize_Class_Record
once to create the new widget "type" (used G_New). There I add style properties like this:
I am impressed ! I have never had the courage to actually use those properties in my code...
...
Ada 2X supports Unicode and GNAT supports Unicode sources.
I never tried it but I suppose the following should work:
Strings_Edit.UTF8.Handling.To_UTF8 ('€');
Here '€' should be resolved to Wide_Character'('€') and then converted to a UTF-8 encoded String.
As for labels, icons etc, I use GTK style properties.
P.S. Inventors of GTK CSS sheets apparently misspelled the word "sheet", they should have used the letter 'i'! (:-))
Being German, I need umlauts and € together in strings to write them to some labels.
Using Character'Val (16#E2#) & Character'Val (16#82#) & Character'Val (16#AC#)
complicates things, since umlauts are above 255 and need transformation to UTF8,
whereas the euro sequence above is already in UTF8 and must not again be transformed.
What a mess!
Being German, I need umlauts and € together in strings to write them to some labels.
Using Character'Val (16#E2#) & Character'Val (16#82#) & Character'Val (16#AC#)
complicates things, since umlauts are above 255 and need transformation to UTF8,
whereas the euro sequence above is already in UTF8 and must not again be transformed.
What a mess!
When converting to UTF8, can you specify that you are using Latin-9 (ISO-8859-15), instead of Latin-1? Latin-9 is equivalent to Latin-1 plus
the Euro sign, instead of the generic currency sign, since Latin-1
predates the Euro.
In that case, it would be:
Euro_Sign : constant Character := Character'Val (164);
This is from Ada.Characters.Latin_9, provided by GNAT (not in the
standard). Not sure, buy maybe you could type the Euro sign in the
source code with the keyboard, since the representation is the same.
Another option is to use ASCII only (with some encoding for umlauts and
Euro sign) and then apply localization for the strings that must be "translated" to proper German.
In Gnat Studio, you can set the encoding (from the file's context menu choose "Properties...") to Latin_9. Then the character 164 is displayed as €
in the Ada source file. You can even use the € key on the keyboard. That does not help, however, since Unicode is based on Latin_1, and when this
is transformed to UTF8, the currency character appears on the GtkAda GUI.
Being German, I need umlauts and € together in strings to write them to some labels.
Using Character'Val (16#E2#) & Character'Val (16#82#) & Character'Val (16#AC#)
complicates things, since umlauts are above 255 and need transformation to UTF8,
whereas the euro sequence above is already in UTF8 and must not again be transformed.
What a mess!
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 365 |
Nodes: | 16 (2 / 14) |
Uptime: | 06:46:34 |
Calls: | 7,785 |
Files: | 12,914 |
Messages: | 5,750,442 |