Confused - "£" converted to "�"
dazinator opened this issue · comments
Darrell commented
My CI build just ran a dotnet format on my code (luckily PR branch) and pushed up the changes.
One of the files it corrected orignally had this c# code
_mocked.Setup(x => x.GetCurrenciesAsync(It.IsAny<string[]>(), default))
.Returns(Task.FromResult<IList<CurrencyDto>>(new List<CurrencyDto>()
{
{ new CurrencyDto(){ Id= 1, IsBase = true, IsUnit = true, Symbol = "£", Code = validCurrencyCode , Name= validCurrencyCode} }
}));
The formatted version, the £
symbol has been changed to "�":
_mocked.Setup(x => x.GetCurrenciesAsync(It.IsAny<string[]>(), default))
.Returns(Task.FromResult<IList<CurrencyDto>>(new List<CurrencyDto>()
{
{ new CurrencyDto(){ Id= 1, IsBase = true, IsUnit = true, Symbol = "�", Code = validCurrencyCode , Name= validCurrencyCode} }
}));
dotnet format is run during our azure devops build pipeline, its run on an ubuntu docker container
here is header info
Starting: dotnet format
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.221.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
/azp/_work/_tool/dotnet/dotnet format --no-restore --verbosity diagnostic
The dotnet runtime version is '6.0.6'.
The dotnet CLI version is '6.0.301'.
Using MSBuild.exe located in '/azp/_work/_tool/dotnet/sdk/6.0.301/'.
Formatting code files in workspace '/azp/_work/1/s/src/foo.sln'.
Sam Harwell commented
Can you verify that the source files in the repository are encoded as UTF-8 with byte order mark? This is the default encoding for C# files and is used to prevent this issue from occurring.