dhanshreeA
dhanshreeA

Reputation: 208

Is file format different from file extension?

I don't understand how files are stored. I opened my text editor, wrote down some gibberish and saved it as .pdf, and then tried to open it with a pdf reader. The pdf reader could not open it. Someone please explain what happened here?

Upvotes: 0

Views: 2913

Answers (3)

Amadan
Amadan

Reputation: 198556

Let's say you have a folder system in your office, that says "English documents go into brown folders; Spanish documents go into pink folders; French documents in red folders; Japanese documents in white folders;..."

If you put "これは英語じゃね〜よばか" into a brown folder, it doesn't make the text English. It just means you put it into a wrong folder. If you put "egu egu egu egu egu" into a Japanese folder, it doesn't stop being gibberish.

File extension is a part of a file name that we use by convention to mark what kind of content a file has (kind of like a folder colour). File format is the structure of the content a file has (kind of like knowing what language to use to read the paper within).

Extensions are primarily for users, so we know what each file has, and also a shortcut so OS can open a file with an application it thinks is suited for it (just like one could see a brown folder and decide it should go to the English-speaking employee).

Just like a Japanese speaker will be able to read a Japanese text in a brown folder (if explicitly handed one), a PDF reader will be able to read a PDF-format document, whatever the extension (if you make the PDF-reader open it, rather than relying on the OS to figure out the correct application). Just like no-one can read "egu egu egu egu egu" despite its folder's claims of it being Japanese, the PDF reader is confused to find a non-PDF-formatted content inside a .pdf extension file.

Upvotes: 5

Furgas
Furgas

Reputation: 2844

File extension is part of file name so it's just a label. You won't change file format by changing its label just as changing the name of the shortcut on your desktop from "MS Word" to "Battlefield 2" won't magically allow you to play this game for free:)

Upvotes: 0

Said
Said

Reputation: 699

File extensions and file formats are often spoken about interchangeably. In reality, however, a file extension is just the characters that appear after the period, while the file format speaks to the way in which the data in the file is organized.

So, in your example, you have created file in txt format and manually updated extension to .pdf. PDF reader thinks that it can open that file (since it has .pdf extension), but it wasn't able since it's formatted as txt.

To sum, you can change extension, but no format. In order to change format, you have to use some kind of converter.

Upvotes: 0

Related Questions