QtCreator error could not decode with "UTF-8" Editing not possible.
-
Hello,
on Ubuntu 16.04 my QtCreator 4.7.2 complains when editing files with locale carachters "èéàòì" even if they are into comments.This is the error:
Error: Could not decode "filename.cpp" with "UTF-8"-encoding. Editing not possible.
How can I solve that?
TIA -
You can run the command
file filename.cpp
to get more information about the encoding.Most likely the file was created on Windows and has Latin-1 encoding. However, Qt (and most modern compilers) requires sources files in UTF-8 encoding.
Regards
-
@aha_1980
thank you for the hint!The files without problems are
C source, ASCII text, with CRLF line terminatorsThe files not editable are
C source, ISO-8859 text, with CRLF line terminatorsWhat do you suggest to do to unify every file in the same right way?
-
Hi @Maruko,
for encoding conversion in Linux this link gives a good overview. You can either convert it to UTF-8 (keeping all characters), or to pure ASCII, which means your characters will be replaced with the most similar ASCII character (e.g. é -> e).
Please note, that CRLF line endings is also not the usual UNIX style, which can hurt you sooner or later.
Git for example, let you checkout files on Windows with CRLF endings, while on Linux it gives only LF to maximise the interoperability.
-
I just discovered this because a header file from FTDI contained a copyright symbol. I just converted that to read (C) instead of the copyright symbol and it was fine.