Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fix iso-8859-2 Encoding warning? #345

Open
SymbioticKilla opened this issue Jun 13, 2023 · 3 comments
Open

How to fix iso-8859-2 Encoding warning? #345

SymbioticKilla opened this issue Jun 13, 2023 · 3 comments

Comments

@SymbioticKilla
Copy link

SymbioticKilla commented Jun 13, 2023

##[warning]Detected file encoding (iso-8859-2) is different to the one specified (utf-8).
Hi,

my .csproj file ist utf-8 and task is also with utf-8 encoding:
image
image

Everything works fine incl. copyright symbol ©.

I just want to remove warning message.

Thanks!

@petersladek
Copy link

Ran into same issue recently. Is there any plan to fix this? Thanks

@bothzoli
Copy link

bothzoli commented Sep 5, 2024

I had the same issue, but was able to fix it for myself adding BOM to my CSPROJ files.
So all I did was opening my CSPROJ files and then save them using the encoding UTF-8 with BOM (in VS Code).
This makes sure the task correctly detects the file as UTF-8.

@bothzoli
Copy link

bothzoli commented Sep 5, 2024

By the way it also seems to be an easy fix to add a "supress file encoding warnings" flag, and change the following part:

function setFileEncoding(file: string, model: models.NetFramework) {
const encoding = getFileEncoding(file);
logger.debug(`Detected file encoding: ${encoding}`);
model.detectedFileEncoding = model.fileEncoding;
if (model.fileEncoding === 'auto') {
model.detectedFileEncoding = encoding;
} else if (model.fileEncoding !== encoding) {
logger.warning(`Detected file encoding (${encoding}) is different to the one specified (${model.fileEncoding}).`);
}
}

as such:

 function setFileEncoding(file: string, model: models.NetFramework) { 
     const encoding = getFileEncoding(file); 
     logger.debug(`Detected file encoding: ${encoding}`); 
  
     model.detectedFileEncoding = model.fileEncoding; 
  
     if (model.fileEncoding === 'auto') { 
         model.detectedFileEncoding = encoding; 
     } else if (model.fileEncoding !== encoding && !model.supressFileEncodingWarnings) { // <-- CHANGE HERE
         logger.warning(`Detected file encoding (${encoding}) is different to the one specified (${model.fileEncoding}).`); 
     } 
 } 

I'm happy to make a PR for this if required, however I think adding the BOM to the files should be sufficient.
However, it'd probably be best to add that to the documentation (maybe here?), which I'm also happy to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants