Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I sometimes need to open text files that are encoded in EUC-KR.

man gedit gives:

   --encoding
          Set the character encoding to be  used  for  opening  the  files
          listed on the command line.

This can be used to open specific files with the desired encoding:

gedit --encoding euc-kr readme.txt

However, each file to be opened requires a similar command to be typed.

I can run iconv on the file(s), but then I have to deal with different file versions.

Do I have better options for dealing with non-utf8 text files?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

The easiest way to specify the encoding when opening the file is to use the Open Files dialog.

On the bottom left, you will see an drop-dwon option for Character encoding. If you haven't used the encoding in Gedit before, scroll down to Add or Remove....

In the new dialog, scroll down the list of Available Encodings until you find the one you want, then click Add to send it to the list of encodings on the right, then OK.

That's it. After that you easily open the file with the correct encoding.

enter image description here

share|improve this answer
1  
That's exactly what I was looking for. I kept looking for it in the File, Edit, Tools, and View menu... –  bdares Apr 18 '13 at 6:22

Nautilus Action

To have access to custom open options for Gedit from the file browser Nautilus we may define a Nautilus Action to have an entry in the right mouse click context menu which opens a selected file in Gedit with certain options. The command line for your action would then be:

/usr/bin/gedit --encoding euc-kr %b

By doing so you will be able to open files with euc-kr encoding on selecting your custom context menu entry but still be able to just double click open other files having a standard encoding.


Custom .desktop file

To be able to select Korean encoding as option in the open with dialog or as standard option we may create a custom kr-gedit.desktop file (e.g. located in ~/.local/share/applications) to include options in the Exec= line. Add this custom "application" to the files properties dialog (on right click on a .txt file).


Alias

For the command line you may define an alias to open files with a Korean encoding. This can also be made permanent:

alias kr-gedit="gedit --encoding euc-kr"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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