9

I have some files that Ubuntu can't read it ( ANSI encoding ) but Windows can read it well.

When I open it in gedit or notepad++ it seems like this :

Êã ÇáÊÍæíá áÜÜ

How can I make Ubuntu read ANSI encoded files well?

1
  • There is really no such thing as “ANSI encoding”. Only a bad joke of some 1980s coders working in Microsoft. Sep 9, 2015 at 20:44

4 Answers 4

5

ANSI means more or less nothing --- the most probable candidate for your encoding is Windows-1252. You can convert the file with

iconv -f WINDOWS-1252 -t utf8 < filein.txt > fileout.txt

but remember, most encodings (read the linked article if you are not sure about what that mean) can't be reliably guessed, so you need to know the exact encoding to give sense to your data.

From the comments it seems that you are most probably looking for some Arabic encoding --- in that case check WINDOWS-1256.

The list of available encodings for iconv is on github, or you can find it with the command

iconv --list 

Notice that just at the start of the list there are a bunch of "ANSI"-like encodings.

0
3

If you don't want to convert it as mentioned in Rmano's answer, you may use Geany or Kate to read/edit them ar they are, default Arabic encoding in Windows is CP-1256 (WINDOWS-1256). Just keep in mind that switching to UTF-8 is recommended over all. It is supported by Notepad++ and Windows default note editor.

Geany

sudo apt-get install geany

geany encoding

Kate

sudo apt-get install kate

kate encoding

1

I was trying to read a file in ANSI mode in ubuntu and was able to do it.

I tried sublime text, gedit, etc. but I was somehow failing, finally I tried the terminal in ubuntu, and cat command helped me.

I opened the terminal in the file location then used

cat filename.txt

And it worked like a charm, if the text file contains the ANSI syntax, it will be displayed properly.

Hope it helps.

1

The gedit can work with files encoded with e.g. Windows-1250. Select "Open", "Additional Documents", Character encoding: "Central European (WINDOWS-1250"). If it is not there, add it there by this option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .