Gnatdoc - Czech characters in UTF-8

Hello. I use Czech comments in my programs with UTF-8 encoding in Linux environment. However, when I run “gnatdoc -P “project name””, the Czech characters are not interpreted correctly. I tried to generate the documentation for example from the spider.adb file (from the book Ada_95_Problem_Solving_Program_Design) and the encoding is set correctly: “file -i spider.adb - spider.adb: text/plain; charset=utf-8”. ChatGPT advised me to try the appropriate “gnatdoc --encoding=UTF-8” switch, it looks like the current version of gnatdoc no longer supports it (https://docs.adacore.com/live/wave/gnatdoc4/pdf/gnatdoc-doc/gnatdoc_ug.pdf).

Comments block in spider.adb file:

(----------------------------------------------------------------------
–| Tento balíček poskytuje procedury pro simulaci příkazů pavouka.
–| Pavouk se může pohybovat po obrazovce a kreslit jednoduché vzory.
–| Tato verze je určena pro obrazovku 24 x 80 znaků.
–| Původní autor: John Dalbey, Cal Poly San Luis Obispo, 1992
–| Upravil: Michael B. Feldman, The George Washington University
–| Poslední úprava: Prosinec 1998
----------------------------------------------------------------------)

I see in the html output generated by gnatdoc as:

-------------------------------------------------------------- | Tento balíček poskytuje procedury pro simulaci příkazů pavouka. | Pavouk se může pohybovat po obrazovce a kreslit jednoduché vzory. | Autor: John Dalbey, Cal Poly San Luis Obispo, 1992 | Upravil: M. B. Feldman, The George Washington University | Poslední úprava: Prosinec 1998 --------------------------------------------------------------

This small project is is available for download here in Czech “úschovna” online service: “Zásilka | Úschovna.cz”.

Is it possible to set gnatdoc for correct use with Czech characters?

I don’t use gnatdoc myself, so I don’t have a good answer. If you don’t get enough traction here, you can also try posting an issue at the repo for it:

I don’t reproduce that with gnatdoc from GNAT GPL 2019, which is the one I use for ASFML, but if you are using gnatdoc from the Alire index, that one is very different, and you might not want to switch it.

It might depends from the version of GNATdoc. Latest version of GNATdoc uses UTF-8 encoding when -gnatW8 switch is specified for compiler. Otherwise it fallback to safe extended ASCII (like Latin-1) encoding.

Thank you very much for the reply, yes, so far it looks like I can’t solve the problem, so I will consider adding this to the github project.

Thank you for the reply, I’m using the Arch linux distribution and I’ve tried using the gnatdoc package from the AUR repository and the gnatdoc crate from Alire still with the same result. So I will consider adding the issue to the github project.

Aha, I didn’t know that the current version of gnatdoc uses utf-8. I have tested the -gnatW8 or -gnatWu switch before when testing unicode variable names. I’ve tried translating the individual files in a simple project (gnatmake -gnatW8 screen.adb, spider.adb and spider_demo.adb) and then in a project using gpr (I added the line “for Switches (“ada”) use (”-gnatW8")" to spider_demo.gpr)"), but after “gnatdoc -P spider_demo.gpr” command the problem persists:

------------------------------------------------------------ | Procedury pro kreslenà na ANSI terminálovou obrazovku | Autor: M. B. Feldman, The George Washington University | Poslednà úprava: Červenec 1998 ------------------------------------------------------------

Can you please try adding utf-8 characters to comments on any of your simple program with the -gnatW8 switch and then running gnatdoc? If this doesn’t help either, I guess I have no choice but to report the bug to the project’s github.

This feature was added recently, see

1 Like

Привет, Vadim. Thank you very much for the information, my AUR package in Arch Linux is older than the commit 58e45e5 and therefore did not respect the -gnatW8 directive and the same with the current Alire package. After supplying the current github source and recompiling the package, the problem is already solved, if I add the -gnatW8 directive to the gpr or alire project, the documentation generation is already fine:

-------------------------------------------------------------- | Tento balíček poskytuje procedury pro simulaci příkazů pavouka. | Pavouk se může pohybovat po obrazovce a kreslit jednoduché vzory. | Autor: John Dalbey, Cal Poly San Luis Obispo, 1992 | Upravil: M. B. Feldman, The George Washington University | Poslední úprava: Prosinec 1998 --------------------------------------------------------------

I’m very happy that Ada now has complete support for world languages and wonderful people who are happy to help.

2 Likes