Neeraj Bansal
Neeraj Bansal

Reputation: 390

iconv command is not changing the encoding of a plain text file to another encoding

In Linux I created a plain text file. using "file -i" I am seeing file encoding is "us-ascii" . After trying below commands it is still showing output file encoding as "us-ascii". Could you please tell me how to change encoding? or Is there any way to download some encoded file which I can't read.

  1. iconv -f US-ASCII -t ISO88592//TRANSLIT -o o.txt ip.txt
  2. iconv -f UTF-8 -t ISO-8859-1//TRANSLIT -o op.txt ip.txt

I am expecting either iconv change the encoding or I can download some encoded file.

Upvotes: 0

Views: 1143

Answers (1)

Codo
Codo

Reputation: 78855

If your file contains only ASCII character, then there's no difference between the ASCII, UTF-8 and different ISO8859-x encoding. So after conversion, you will end up with the exactly same file.

A text file does not store any information about what encoding was used. Therefore, the file applies a few rules but at the end of the day, it's just a guess. And as the files are identical, the result will alwazys be the same.

To see a difference, you will must use characters that are encoded differently with the different encoding or are not avaialbe at all in one of the encodings, e.g. ă, € or 😊.

Upvotes: 1

Related Questions