Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check file encoding in Linux? Handling multilingual scripts

My company has php scripts with texts in different languages (including french, german, spanish, italian and english).

Developers decided to use Latin-1 encoding as base for everyone, so this way nobody will override file encoding and corrupt foreign languages in it. (At first some developers used html entities, but this way is not preferred)

I have few questions for you:

  1. How can you check file encoding on linux?
  2. If you had experience working with files in different languages, how did you manage to not override encoding of others?

Thanks for any advise in advance

like image 261
Kelvin Avatar asked Dec 17 '22 02:12

Kelvin


2 Answers

file gives you informations about a file, including, charset, languages, etc.. depending on file type.

Use --mime-encoding to get only the information you want.

like image 147
Boris Guéry Avatar answered Feb 22 '23 23:02

Boris Guéry


Developers decided to use Latin-1 encoding as base for everyone, so this way nobody will override file encoding and corrupt foreign languages in it.

Latin-1 can't handle most languages. Flavours of Unicode (typically UTF-8) are preferred.

How can you check file encoding on linux?

With the file utility. It can only guess though.

If you had experience working with files in different languages, how did you manage to not override encoding of others?

Sensibly configured editors.

like image 40
Quentin Avatar answered Feb 23 '23 01:02

Quentin