Skip to content

Only write UTF-8 BOM where needed #5239

@mgabeler-lee-6rs

Description

@mgabeler-lee-6rs

Describe the feature or problem you’d like to solve

Not all CLI text editors handle UTF-8 BOMs "nicely" -- haivng it visible and needing to navigate over it, and be sure not to leave it in the middle of an edited file (such as a merge message) is not great for users.

Proposed solution

The code that writes the BOM has a comment indicating that it exists just as a hint/workaround for notepad.exe on Windows:

// The reason why we do this is because notepad.exe on Windows determines the
// encoding of an "empty" text file by the locale, for example, GBK in China,

If that comment is accurate, then the BOM writing could simply be limited to only running when runtime.GOOS == "Windows"?

If this is safe, it will make message editing a better, and less error-prone, experience for users on platforms that don't need it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcomewindowsRelated to Windows hosts or runners

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions