My system locale is ru_RU.KOI8-R and I want geany to create all new files in this encoding. In its settings I set "Default encoding (new files)" to "Cyrillic (KOI8-R)" and it works for new files. But when I open any file without cyrillic characters, geany thinks it's in Unicode.

Is there any way to tell geany to open all files in KOI8-R (even if there's no non-ASCII characters inside them) or the only way is to put any character from upper half of codepage to all source files?


I tried to work on this problem, but seems that the only way for Geany to force to use an encoding is to have a corresponding line in the beginning of the file. If file contains UTF-8 characters geany will use this locale.

Among other things i tried the following bellow. You can also give a try your self , in case that works better in your machine.

  • To switch localle of my system to Greek ISO-8859-7 (it was en_US.UTF-8 before). I had to first install the new local using dpkg-reconfigure locales

  • To convert a test file from UTF-8 to desired locale (ISO-8859-7 in my case) using command iconv -f UTF-8 -t ISO-8859-7 c.txt --output=c2.txt

  • To change geany preferences , in Preferences-Files Tab applying Greek ISO-8859-7 encoding both for new files and also for "Default Encoding (existing non Unicode Files)"

PS: Setting can also be verified/changed directly by look/edit file ~/.config/geany/geany.conf and look for the lines pref_editor_default_new_encoding=UTF-8 #changed to ISO-8859-7 and line pref_editor_default_open_encoding=None #changed to ISO-8859-7

  • Then only thing that really worked is to insert in the beginning of the file the line :
    # geany_encoding=ISO-8859-7 #

This solution is described on the Geany online manual - Infile encoding specification Section.

As a workaround to avoid opening all your files one by one and appending the above line you could use:

echo -e "# geany_encoding=ISO-8859-7 #\n$(cat c.txt)" >c.txt

You can also make a loop to quickly "geany-convert" all your files; something like this:

for file in "$(find . -type f -name "*.txt");do echo -e "# geany_encoding=ISO-8859-7 #\n$(cat $file)" >$file;done

I hope above ideas to help you solve your problem.

You could also check and ask geany devs if forcing encoding during opening a file is in the future plans of Geany.

PS: You could always open the file as it is in Geany, press reload as <your encoding> and save. This should save the file in the new encoding.

  • Thank you! //geany_encoding=koi8-r at beginning of each file solve my problem. Where did you find such an "undocumented feature"? – Eddy_Em Jan 27 '17 at 12:20
  • 1
    @Eddy_Em Welcome :-) Happy that this helped. Online manual of Geany has tons of information available. I already updated my answer to include the Geany Online Manual link (geany.org/manual/#in-file-encoding-specification) . PS: If you are happy with above solution you might consider to accept this answer. – George Vasiliou Jan 27 '17 at 12:58
  • @George Vasiliou. Good job done, the problem was long-lived. And now solved! Thank you!. – WebComer Nov 16 '18 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.