# Is it possible to solve encoding problems?

I have some tex files that are corrupted, meaning that characters like accented letters have been replaced with weird symbols. Is it possible to solve this kind of problem after the weird symbols appear, or is it already too late?

Sometimes when I save some tex files (where the encoding has been set to latin1) and open them again, maybe in some other editors, all the special characters are lost and I need to manually retype them in.

\documentclass{article}
\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\begin{document}
\section{Section}
à è ì ò ù
\end{document}


In this example, the five accented letters would be replaced with other symbols, and I haven't found any way to recover the original version of the file.

I know that setting utf8 in the inputenc package solves this problem when I create new files, but what about recovering older latin1 files which, upon opening, are filled with corrupted characters?

-
Could you please provide a Minimum Working Example (MWE) that includes all packages dependencies and some text that produces you problem. –  Peter Jansson Jan 12 '13 at 10:20
Tools such as recode or iconv can help. –  Paul Gaborit Jan 12 '13 at 10:22
Your question applies to text files in general; this suggests that it might be easiest to search for such general solutions, using keywords such as "repair", "encoding", "email", "fix", and "text". –  Lover of Structure Jan 12 '13 at 10:24
@user1301428 If you use OSX or Linux, you are lucky. Both include the program iconv which you can use from a terminal with the following syntax iconv -f utf-8 -t latin1 < your-weird-file > new-fixed-file. Alternatively, you can use an editor which properly shows utf8. –  JLDiaz Jan 12 '13 at 12:32
You might also want to check out a konwert tool (is in Ubuntu repo, I don't know about Mac). It is kind of a Swiss-army knife for converting files between encodings, imho better than iconv. Among others, it can (try to) recognize the encoding. –  mbork Mar 20 '13 at 6:34