Tomi Mester
Tomi Mester

Reputation: 109

Character Encoding Issue on Ubuntu/Bash

I'd like to cat a Swedish txt file.

For special characters (like ä or é) I get back these characters: �.

eg. �r han fr�n Apornas planet.

I have multiple files from multiple sources and some of them gives back the correct results, (Eg. Det här är fel!) some of them produces the above mentioned issue.

Based on that I'm pretty sure, that the issue is with the file's character (en)coding, but I just simply can't find how to encode the file at the command line.

I've tried:

iconv -f UTF-8 -t UTF-16 file.txt

and similars. But I've ended up in an error message all the time.

Do you have any tips? Thanks!

Upvotes: 1

Views: 1960

Answers (1)

Tomi Mester
Tomi Mester

Reputation: 109

Based on comments the solution was:

First execute:

chardet file.txt

to find out the character encoding.

Then:

iconv -f iso-8859-1 -t utf-8 file.txt

to create the "translation".

Upvotes: 1

Related Questions