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

Fix copyright symbol encoding; force UTF-8-BOM encoding for C# files #526

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

n-ski
Copy link
Contributor

@n-ski n-ski commented Dec 9, 2023

Issue

When opening some files in IDEs like Visual Studio or Rider, the developer gets notified that file was opened with UTF-8 encoding. In case of Visual Studio, it tells you that some characters were replaced with substitution character (�) and saving the file will not preserve the original contents; Rider also performs character replacement but preserves the original contents when file is saved.

Visual Studio 2022

Shows up as modal window, forces you to interact with it.

Rider

Shows up as notification in the notification bar above the code editor, can be ignored.

The reason why it's happening is that some files are encoded in ISO-8859-1 where the copyright symbol is a single byte (0xA9), which is incompatible with UTF-8 and forces an IDE or a text editor to perform the character substitution.

Changes

  • The copyright symbol is encoded as proper UTF-8 code point.
  • Replaced weird apostrophes in HtmlWeb.cs file with ASCII apostrophes ('). Those were either not rendered or rendered as �, depending on IDE/text editor.
  • Re-encoded all C# files in UTF-8-BOM encoding.
  • UTF-8-BOM encoding for C# files is now enforced in IDEs/text editors that support .editorconfig. I chose UTF-8-BOM because it's the default one Visual Studio uses for C#-related files and almost every file in the solution is already encoded in UTF-8-BOM.

Result

The developer doesn't get annoyed with notifications/popups and in case of Visual Studio one doesn't need to be careful not to accidentally commit the substitution character.

n-ski added 2 commits December 9, 2023 21:35
In some files the copyright symbol is encoded in ISO-8859-1 as single
byte (0xA9) which is incompatible with UTF-8. This causes most text
editors and IDEs to render the symbol as � because by default they
assume a file is encoded in UTF-8 when no byte order marks are present.

Also fixes apostrophe symbols in HtmlWeb.cs file.
@JonathanMagnan JonathanMagnan self-assigned this Dec 11, 2023
@JonathanMagnan
Copy link
Member

Hello @n-ski ,

Thank a lot for your contribution.

We will review and merge it this week.

Best Regards,

Jon

@JonathanMagnan
Copy link
Member

Hello @n-ski ,

Thank you again for your contribution. Your fix is now merged.

The BOM issue might come back on a few files later today, as the current source is not actually on GitHub. I will move all our latest updates to GitHub and keep only our personal projects in our private repository instead, which makes a lot more sense.

Best Regards,

Jon

@JonathanMagnan JonathanMagnan merged commit f938a13 into zzzprojects:master Dec 13, 2023
@n-ski n-ski deleted the fix-copyright-char-encoding branch December 13, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants