Skip to content

Asp.net core .cs file encoding is not uft-8 encoded #37201

Closed as not planned
Closed as not planned
@vsfeedback

Description

@vsfeedback

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.

  1. Install Windows 10 Swedish version
  2. Install Visual Studio 2019
  3. Create a new Web Project (.net Core)
  4. Add a razor page
  5. 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:

  1. Create a C# ASP.NET Core Web App project.
  2. Open Pages > _ViewImports.cshtml and edit it.
  3. Go to File > Save _ViewImports.cshtml As…
  4. Click “Save with Encoding…”
    The Encoding shows “Western European (Windows)” instead of “Unicode(UTF-8 with signature)”.
    Actual.png

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Author: Migration Bot 🤖The issue was created by a issue mover bot. The author may not be the actual author.Priority:2Work that is important, but not critical for the releasearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions