How does gedit detect the encoding of a text file? [duplicate]

Solution 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.