How to know file encoding?

how can i know what format a file is

  • example:

UTF-8
ANSI
UCS2

i am in a...

Well usually

file file-name 

should give you a good start...

1 Like

excellent function

Now how can I change it from ASCII to UTF-8 and vice versa?

ASCII is a subset of UTF-8. But if there is a need to transliterate, try something like:

iconv -f UTF-8 -t ASCII//TRANSLIT < input_file
2 Likes

it doesn't work it gives me this error

new_vulcano:/Odbms/sdi/odbms/export/done->iconv -f UTF-8 -t ASCII//TRANSLIT < StockProtegidoPMM_20190819.csv
iconv: 0791-004 cannot open converter

That looks like you may possibly be running on AIX, please give us your UNIX OS and shell.

The error means iconv cannot find the language file it needs to make the conversion. Finding what language files you do have requires that you give us more information about your system. Also dropping the //TRANSLIT might help. You may end up with garbage, too.

1 Like
new_vulcano:/Odbms/sdi/odbms/procesos->uname -a
AIX new_vulcano 1 6 00C640C74C00
new_vulcano:/Odbms/sdi/odbms/procesos->
echo junkword | truss iconv -f UTF-8  -t ASCII//TRANSLIT   2>&1|grep Err

Every missing file will show up with ENOENT as the last word. Where you get the files you need, I do not know. An AIX expert can probably help, which is not me.

ENOENT is the return error code moniker meaning no file by that name can be found.

You could try iconv -l to get a list of the supported character set encodings.

Conversion to ASCII may give "illegal input sequence" errors for the French/German accented characters like: Théâtralité try ISO8859-1 should give the high ASCII value normally used in windows.

1 Like