Description
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
When creating a new razor file, the cshtml file gets UTF-8 encoded but the .cs file is ANSI encoded.
This happens if you are using a swedish windows operations system with latest VS2019.
It is very easy to reproduce.
- Install Windows 10 Swedish version
- Install Visual Studio 2019
- Create a new Web Project (.net Core)
- Add a razor page
- Check the encoding for the newly created .cs file by doing "Save as" and select "Save with different encoding" in VS.
It might sound like a small issue but it's not.
When developing code to run on AKS, the file encoding is extreamly important.
Lets say you have a file with a comment containing. UTF-8 charaters. It will compile fine on you local machine, all tests will pass, but when you check in your code and compile it on a Linux machine, it will fail.
For every file you add you need to manually change it's encoding to UTF-8. Please fix this asap.
Please don't ask me for more information. This is 100% reproducable.
Original Comments
Feedback Bot on 5/16/2021, 08:12 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Jiahui Zhang (Beyondsoft Corporation) [MSFT] on 5/25/2021, 00:12 AM:
Thank you for your feedback! We tried to reproduce this issue with following steps:
- Create a C# ASP.NET Core Web App project.
- Open Pages > _ViewImports.cshtml and edit it.
- Go to File > Save _ViewImports.cshtml As…
- Click “Save with Encoding…”
The Encoding shows “Western European (Windows)” instead of “Unicode(UTF-8 with signature)”.
Is it the behavior of this issue? If yes, we will go through a further investigation. If not, could you help to correct us?
We are looking forward to your reply!
per.bornsjo on 5/25/2021, 00:27 AM:
Yes, that’s the problem!
Both the .cs and the .cshtml should be UTF-8.
Feedback Bot on 6/2/2021, 02:38 AM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
Original Solutions
(no solutions)