Encoding problem. Files opened with UTF-8 without any warning/error

Answered

Hello,

I use Intellij 2018.1 and I have an annoying problem. 

Maven project with Cp1252 encoding (defined on poms), everything uses Cp1252.

 

Some files in the project probably have some UTF-8 characters so the file is opened as UTF-8. The main problem is that there's no warning (even with the Inspection checked) so if I write any special character like àèìòù, the same characters decoded as UTF-8 get converted some way and it generates problems.

 

The main thing I'd like to have is a warning/error which tells me the file was opened with UTF-8 when the project is defined to use CP-1252.

Thanks for any help.

0
7 comments
Avatar
Yaroslav Bedrov

Hello Fabio,

Actually there should be a message that file was opened in the wrong encoding. Is it possible to provide any file demonstrating the issue?

 

0
Avatar
Permanently deleted user

I can provide a file, however I remember that message (at the top of the screen), but I didn't see it anymore, maybe after an update in the last 3-4 months. Is there any way it could be disabled? 

I didn't turn off the inspection.

0
Avatar
Permanently deleted user

I tried to re-create the error which I found in the following strings (there are more characters of course) :


final String s3 = "òóôõ ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ" +
"רÙÚÛÜÝÞß [€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—" +
"˜™š›œžŸ<NBSP>¡¢£¤¥¦§¨©ª«¬<SHY>®¯°±" +
"²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ" +
"רÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷";
final String eAcute = "é";


I wrote the strings using UTF-8. If I convert to Windows1252 and I look at differences,
I get the error at the top of the file "Content was decoded with errors (using 'Windows-1252' charset).
I can't find it anywhere else. I'm not sure that's how it worked 4-5 months ago (I kept updating IntelliJ).

I remember I would get notified if an error was present. Don't know how to solve it.

0
Avatar
Yaroslav Bedrov

Fabio,

We have related issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-178380

 

1
Avatar
Permanently deleted user

I've read that post but I couldn't find any solution yet. Is the issue hard to solve or just random? 

0
Avatar
Yaroslav Bedrov

Fabio,

It's not fixed yet. We'll provide fix as soon as possible.

 

0
Avatar
Permanently deleted user

Thanks for help.

0

Please sign in to leave a comment.