[Qt-creator] "Editing not possible" solution

Ziller Eike Eike.Ziller at theqtcompany.com
Fri Jan 23 14:24:30 CET 2015


> On Jan 21, 2015, at 7:20 AM, Frédéric Marchal <frederic.marchal at wowtechnology.com> wrote:
> 
> 2015-01-20 23:48 GMT+01:00 Pawel <pawelfaron87 at wp.pl>:
>> Hello,
>> 
>> In my company we work in multinational teams. Many people uses strange file
>> encodings and they don't plan to change it...
>> In QtCreator I quite often see the "Editing not possible" error. I know that
>> file decoding is a difficult subject, but I'm sure we can do better than
>> this.
>> 
>> I've implemented simple code to help a bit. It is located in
>> textdocument.cpp, and differs from current solution with:
>> 
>> - [Current solution] In functions read() when decoding with default codec
>> fails we return error.
>> - [My Solution] In functions read() when decoding with default codec fails I
>> try all available codecs (QTextCodec::availableCodecs()), and if any one
>> success I return success.
>> 
>> What do you think about this?
> 
> It's very likely not going to work:
> http://en.wikipedia.org/wiki/Charset_detection
> 
> "Character encoding detection, charset detection, or code page
> detection is the process of heuristically guessing the character
> encoding of a series of bytes that represent text. The technique is
> recognized to be unreliable[...]".
> 
> Many character encodings cannot be distinguished except by the fact
> that the text, when decoded with the wrong encoding, looks like
> gibberish to a human reader.
> 
> It is not possible to automate it.
> 
> What would be more reasonable is to have one fallback encoding when
> UTF-8 fails and a BOM was expected.
> 
> Without BOM, it is unreliable and would fail if the file contains some
> characters from another character set but that happen to match valid
> UTF-8 sequences. In that case, the file would be wrongly opened as
> UTF-8.

If you set an encoding to use in Qt Creator, either globally or for your project, then files that have UTF BOM are opened as UTF, and all others are opened with that encoding you set. Do I understand correctly that this is what you propose here as well?

++ Eike

> Frederic
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
Eike Ziller, Senior Software Engineer - The Qt Company GmbH
 
The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list