Reputation: 1405
I have a couple of files that are not analyzed with the following message:
Invalid character encountered in file [file name with full path] at line 9 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
In Visual Studio when I select File / Advance Save Options, the files were set to Western Europe (Windows) - Codepage 1252.
I changed it to Unicode (UTF-8 with Signature) - Codepage 65001.
But SonarQube still complains about the invalid characters. The "invalid characters" are comments in German with Umlaut-characters (ä,ö,ü)
What can I do to fix this (without removing the comments)?
Upvotes: 7
Views: 16364
Reputation: 17851
I got the same error Invalid Character encountered in file
when XML
files were analyzed. And I already had sonar.sourceEncoding=UTF-8
in my properties file.
The problem was I didn't have XML plugin installed in Sonar. Once I installed that via Update Center
, this issue for resolved. Hope this helps anyone else facing this issue.
Upvotes: 0
Reputation: 3011
The SonarQube Scanner for MSBuild and the SonarQube C# plugin currently expect all files of the project to have the UTF-8 encoding - and this is hardcoded.
There is a ticket to improve this in a future version: https://jira.sonarsource.com/browse/SONARMSBRU-174
Upvotes: 3