3

It appears that there are at least two questions here on Ask Ubuntu that are similar to this, but neither has been answered.

Text files can be valid under multiple encodings simultaneously. I would like to know the exact encoding gedit uses to decode a given file. Can this be done in the recent versions of gedit?

(I'd like to note that I am aware of other tools that can determine the encoding of a given file. However, I want to know the encoding as detected by gedit specifically)

4
  • 1
    Gedit lets the GTK libraries do the heavy lifting. There's even a GTK error for the cause where it couldn't detect the encoding: GTK_SOURCE_FILE_LOADER_ERROR_ENCODING_AUTO_DETECTION_FAILED. If you want to dig through the GTK source to see what exactly it does, you might start in gtksourceview/gtksourcefileloader.c. – muru Aug 15 '17 at 7:10
  • Also, Gedit does not save the encoding in metadata unless you overrode the default, so gvfs-info is not useful either. – muru Aug 15 '17 at 7:22
  • Thank you. Do you know if Gedit can expose GTK encoding information to the user in any way (settings, thrid-party plugins, etc)? – Timo Aug 15 '17 at 8:33
  • 2
    Plugins probably can. See the Gedit.Document.get_encoding() method. I don't think I have seen a relevant setting. – muru Aug 15 '17 at 15:07
1

As of the time of this writing, It seems that gedit does not officially expose the character encoding used to decode an open document.

Gedit does show some encoding in the Save As dialog window. It is likely that this is the encoding that was used to decode the original file. However, without inspecting the source code of your version of gedit, there is no guarantee that the encoding shown is the actual encoding used.

Muru has indicated (above in the comments section) that gedit exposes encoding information to plugins. I have yet to come across a plugin that adds this information to the gedit's user interface.

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.