[texworks] texworks and encodings

Stefan Löffler st.loeffler at gmail.com
Sat May 21 10:09:21 CEST 2011


Hi,

On 2011-05-20 16:20, Lars Madsen wrote:
> Wouldn't it be possible for TW to detect the encoding and switch to
> that encoding when working with this file.

The answer to this question is manifold.
As Herbert already pointed out, encoding detection is essentially
guessing (and often requires language-detection as well). Of course I
agree that ideally, Tw should "just work", no matter what file is thrown
at it, but...

In many (simple) situations I don't expect this to be a problem. As long
as you only deal with your own documents, e.g., you can either use the
default utf-8 (preferred) or - especially in cases that you want to work
with other files created by a different program - change the default
accordingly.

If you use non-ASCII characters, you need the inputenc package, AFAIK.
So you should at least be aware that a thing like encoding exists and
can possibly cause problems.

Only when dealing with files with using different encodings this causes
problems, but in that case it's certainly the safest to add information
about the encoding near the top of the file, which Tw picks up similar
to TeXShop. Moreover, others who may want to work with the file can also
quickly see what encoding was used and take the necessary steps without
having to contact the original author to figure out what encoding to use.

So far for the practical aspects. In addition, there are a few technical
issues involved:

Qt doesn't support encoding-detection.

Using additional libraries creates additional dependencies (which
possibly complicate building the program, at least on some OSs). And
they increase the size of Tw. The unicode ICU library for example has
18.7 MB on my Linux system!

So, the bottom line is: it would be great to have it, but the cost is
rather high, and (I hope) the encoding issue only affects a minority of
Tw users. FWIW, I recently added the possibility to "reload a file using
a selected encoding" to avoid having to go to a different editor to add
the "%!TEX encoding" modline. This was also added to the manual, and
should be included in the upcoming 0.4.1 release.

HTH
Stefan


More information about the texworks mailing list