Kile document doesn't work well in WinEdt. How do I convert it?

If I save a document in Kile (on Linux) and and open it in WinEdt (Windows) my text is in a bad format.

For example:

If I have a kile document named main.tex (saved using the UTF-8 encoding) with:

\documentclass[a4paper,12pt,fleqn,oneside,openright]{book}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuges,brazil,brazilian]{babel}

\begin{document}

\chapter{Introdução}\label{Chapter:Introduction}

\section{Apresentação}\label{Section:Presentation}

Este é um texto em português, com várias acentuações. % This is a brazilian portuguese text with several accents.

\end{document}


My output using Kile is:

But opening the same file in WinEdt I get something like:

\documentclass[a4paper,12pt,fleqn,oneside,openright]{book}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuges,brazil,brazilian]{babel}

\begin{document}

\chapter{IntroduÃ§Ã£o}\label{Chapter:Introduction}

\section{ApresentaÃ§Ã£o}\label{Section:Presentation}

Este Ã© um texto em portuguÃªs, com vÃ¡rias acentuaÃ§Ãµes. % This is a brazilian portuguese with several accents.

\end{document}


which is not readable to me.

I did a complete article in Kile, but unfortunately I need it working in WinEdt too, because I need to use the tool tex2word.

If I try to use (copying and pasting) the readable kile document to winedt, for example, using this

\documentclass[a4paper,12pt,fleqn,oneside,openright]{book}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuges,brazil,brazilian]{babel}

\begin{document}

\chapter{Introdução}\label{Chapter:Introduction}

\section{Apresentação}\label{Section:Presentation}

Este é um texto em português, com várias acentuações. % This is a brazilian portuguese with several accents.

\end{document}


my document won't compile and I get errors.

Error:

package utf8x Error: MalformedUTF-8sequence

So, how can I get a readable document (created by Kile) on WinEdt with the same output (readable too)?

• WinEdt is not a UTF-8 editor. Save in a different encoding or use a different editor on Windows. – Joseph Wright Dec 9 '11 at 22:30
• – Torbjørn T. Dec 9 '11 at 22:36
• @JosephWright, do you suggest a encoding supported for both? Readable in Kile and WinEdt? – GarouDan Dec 9 '11 at 23:03
• @TorbjørnT. Very interesting. Don't know this project and I'm installing the kile. Thx to show this to me. – GarouDan Dec 9 '11 at 23:03
• As alternative you could choose another editor with full Unicode support. TeXworks is available for different platforms and shipped with MiKTeX and TeX Live, thus could come in handy here. – Thorsten Donig Dec 10 '11 at 14:32

... WinEdt has currently a limited capability to handle UTF-8 documents. Full support for Unicode is planned when a transition to the new version of Delphi will be completed.

New functionality (like folding and full support for utf-8) is planned for future versions of WinEdt...

This announcement has been on that page since at least a couple of years. The "limited capability to handle" seems to refer to the fact that only a very limited set of Unicode points is manageable.

You can use on Kile an encoding that's managed also by WinEdt, for example Latin-1. Kile has the ability of converting files from the main window (and to use by default a different encoding than UTF-8): see configure Kile to use other encodings

• egreg, Do you suggest a solution to my problem? Maybe I can use another encoding like Joseph Wright said. – GarouDan Dec 9 '11 at 23:12
• You can use latin1. Or a different editor on Windows, such as TeXStudio, that has the other IDEs' look, but supports UTF-8 and installation is simpler than that of Kile. – egreg Dec 9 '11 at 23:21
• thx. I will try latin1. What's your personal recomendation of latex edit on Windows? TeXStudio? – GarouDan Dec 9 '11 at 23:29
• In kile I can use \usepackage[latin1]{inputenc} in the document, but using save as there isn't latin1 format. So I should save as uft8 but using the comand above in the document? – GarouDan Dec 9 '11 at 23:31
• @egreg: He didn't open the document in the correct mode. It would have worked if he had told winedt when opening the document that it is an utf8-file. It would also work if he first makes an empty utf8-document in winedt and then copy&paste from kile. – Ulrike Fischer Dec 10 '11 at 14:25

run inside Linux:

recode --diacritics --touch --verbose UTF-8..latin1 <file>.tex


which converts your tex document into a latin1 decoded which then can be read by WINEdt without any problem. Make a copy of the original file, because a wrong use of recode will damage your file

• Herbert thx, I'll remember. – GarouDan Dec 10 '11 at 14:20

In such cases it can be favorable to choose a semiautomatic input selection by the selinput package from the oberdiek bundle. It selects the input encoding by some glyphs according to the encoding of the source file. For your example it could look like this.

\documentclass[12pt,a4paper,fleqn,oneside,openright]{book}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{%
atilde={ã},
ccedilla={ç},
eacute={é}
}
\usepackage[portuges,brazil,brazilian]{babel}

\begin{document}
\chapter{Introdução}\label{Chapter:Introduction}

\section{Apresentação}\label{Section:Presentation}
Este é um texto em português, com várias acentuações.
\end{document}


Now you can copy and paste this code in whichever editor. It should work out of the box. At least it did for me.

The needed glyphs can be found in the Adobe Glyph List.

• Thorsten Donig, interesting solution. Looks like a bit hard enable all special characters, doesn't it? – GarouDan Dec 10 '11 at 14:21
• @GarouDan: You don't need to add all special characters to the input mappings. Just a few as shown in my example. The rest will be done by the package. – Thorsten Donig Dec 10 '11 at 14:28

Winedt has as egreg already mentioned only restricted utf8 capabilities. But as long as your document uses only chars from one codepage (e.g. the ansinew codepage) it should work fine. (You can also open and compile in winedt documents which uses chars from more than one codepage (e.g. greek and german) but you shouldn't edit and save such documents with winedt).

In the winedt menu you can find under document->samples a document about utf8 in winedt. Besides other informations it also contains a description how to open an external utf8-file in winedt:

... 3. You opened a document in ANSI mode but instead of international characters such as (à,ä,å,æ,ç, etc...) you see a sequence of two or more "strange" looking symbols. Chances are that your document is in UTF-8 format. Close it and use the ":UTF-8"} mode filter in the Open dialog to properly load the document. If you want to make sure that the document will be properly treated from here on you can include a comment: % -*- coding: utf-8 -*- somewhere at the beginning of a document.

I personally have this line at the start of all my utf8-document so that also e.g. emacs opens it correctly:

% -*- mode: TeX -*- -*- coding: UTF-8 -*-