UTF8 code handling in GNAT Studio

I had typed a String whose some characters are accentuated. GNAT Studio seems to have encoded them in Latin1… and my library (GtkAda) had interpreted them as UTF-8.

I have fixed my program with

Msg => "La destination ne peut pas être incluse dans le répertoire source",

But my fix is not very satisfying. Is there a (simple) way to get rid of the ê and é ?

Note: the compiler doesn’t seem happy with things like Character'Val(#16#C3#) & Character'Val(#16#AA#) (illegal character).

You’ll need to turn on UTF8 mode in the compiler using a switch -gnatW8 I think.

Also here is some reference for using UTF8 in GNAT Studio: Using UTF-8 encoding in GNAT | Ada Programming Language

1 Like

I never use Unicode in the source. It must be strictly ASCII 7-bit. To compose UTF-8 strings I use code points. Eg.

Msg => "La destination ne peut pas "    &
       Strings_Edit.UTF8.Image (16#EA#) &
       "tre incluse dans le r"          &
       Strings_Edit.UTF8.Image (16#E9#) &
       "pertoire source",

Furthermore in GtkAda applications I never use string literals for UI texts. All texts I use come from the corresponding widget style property so that they all can be changed in the CSS file without modifying the source code. There exist other schemes too.