Skip to content

non-UTF8 characters are not rendered correctly in Changes and History diff #3923

Open

Description

@vczh

Description

When a source file contains some character that does not appear in the current locale, but the related language package is installed, those code are rendered correctly if you read the diff in Changes tab, but they are not rendered correctly if you read the diff in History tab.

The point is that, if everything is handled correctly in Changes diff, why not do it correctly again in History diff?

Version

GitHub Desktop version: 1.0.13

OS version: Microsoft Windows [Version 10.0.16299.192]

Steps to Reproduce

  1. Set your computer's locale to english
  2. Install Chinese language package
  3. Type some Chinese character to your code
  4. You can see diff shows Chinese characters when you are reading diff from Changes tab
  5. Commit it
  6. Open History tab and read the diff, those Chinese characters are rendered as unrecognizable symbols

Expected behavior: Character correctly rendered (see repro steps for details)

Actual behavior: Character incorrectly rendered (see repro steps for details)

Reproduces how often: 100%

Logs

This is not a crash so I don't think log helps.

Additional Information

You can use Github Desktop to read this change: vczh-libraries/GacUI@92945be , remember to install Chinese language pack while keeping your computer in English. Undo this commit and see things just work in Changes tab, but not in History tab.

Activity

  1. added
    investigation-needed
    on Feb 5, 2018
  2. iAmWillShepherd commented on Feb 5, 2018

    @iAmWillShepherd
    Contributor

    Thanks for taking the time to open an issue! 🙇

    I was unable to reproduce this problem on my computer (macOS).

    2018-02-05_13-35-57 197

    2018-02-05_13-36-04 838

  3. added
    windows
    on Feb 5, 2018
  4. vczh commented on Feb 5, 2018

    @vczh
    Author

    @iAmWillShepherd I am using Windows 10 which is mentioned in the description.

  5. iAmWillShepherd commented on Feb 5, 2018

    @iAmWillShepherd
    Contributor

    Yes, I went ahead and tried to see if I could reproduce on macOS to rule it out. I'm having trouble with my Windows VM, but I intend to check this out there as well.

  6. iAmWillShepherd commented on Feb 23, 2018

    @iAmWillShepherd
    Contributor

    @vczh I was unable to reproduce on Windows 10 as well.

    2018-02-23 11 56 42

  7. shiftkey commented on Feb 26, 2018

    @shiftkey
    Member

    @iAmWillShepherd could there be something in the problem repository and commits like this that are different to your setups? vczh-libraries/GacUI@92945be

  8. iAmWillShepherd commented on Feb 26, 2018

    @iAmWillShepherd
    Contributor

    @shiftkey Yes, I saved all files with the utf-8 encoding. Any other encoding produces blocks.

    I found the code that show's we assume the diff is utf-8 encoded. That may be the issue here.

    function diffFromRawDiffOutput(output: Buffer): IRawDiff {
    // for now we just assume the diff is UTF-8, but given we have the raw buffer
    // we can try and convert this into other encodings in the future
    const result = output.toString('utf-8')

  9. added
    bug
    and removed
    investigation-needed
    windows
    on Apr 9, 2018
  10. shiftkey commented on Apr 9, 2018

    @shiftkey
    Member

    Confirmed the problem commit vczh-libraries/GacUI@92945be does not render correctly in Desktop for Windows and macOS, so I think we need to figure out a way to drop this constraint on rendering UTF-8 diffs.

  11. iAmWillShepherd commented on Apr 10, 2018

    @iAmWillShepherd
    Contributor

    @shiftkey, if we go the route of not requiring strings be encoded as utf-8, wouldn't we have to surface the encoding types to the user? or is there some way for toString to be overridden in such a way as to allow for arbitrary encoding types and picking the right one?

  12. shiftkey commented on Apr 10, 2018

    @shiftkey
    Member

    @iAmWillShepherd yeah, this basically means encoding detection and/or overriding support not unlike #1607

  13. vczh commented on Apr 11, 2018

    @vczh
    Author

    There should be a library to determine (or guess) the encoding from a given stream for JavaScript, like this API IsTextUnicode.

  14. 17 remaining items

  15. mlferreira151276 commented on Apr 13, 2022

    @mlferreira151276

    I'm working with the latest version of Github Desktop and I still have problems with ANSI files

    image

    I'm working with the latest version of Github Desktop and I still have problems with ANSI files

  16. arvanus commented on Nov 17, 2022

    @arvanus

    Same problem here, any idea of when a fix will be available? I'm using git-gui when I commit chars like áçãàü 😢

    image

  17. FozerG commented on Nov 25, 2022

    @FozerG

    Cyrillic with Windows-1251 encoding is not displayed correctly.
    image

  18. steveward commented on Nov 2, 2023

    @steveward
    Contributor

    Another report in #17662.

  19. steveward commented on Jan 17, 2024

    @steveward
    Contributor

    From #18030:

    I have some problems with displaying characters in the GitHub Desktop. My file vers.info is in cp1251 encoding. And .gitattributes contains the next line "*.info working-tree-encoding=C
    P1251 eol=CRLF". In the new part of the file i see correct cyrillic characters, but in the old part I see question signs inside diamonds on the cyrillic characters places.

  20. murchelon commented on Aug 5, 2024

    @murchelon

    I'm not sure that it's just a problem with History. I'm getting this on viewing uncommited changes on a UTF-8 file CSV (without BOM) with diacritics. Is it simply Windows 10 being told to use a font that doesn't have enough glyphs?

    I have the exact same situation: some characters are showing up as a question mark, in a CSV file, in ansi format. If I use a UTF8 file, there is no problem.

  21. steveward commented on Nov 12, 2024

    @steveward
    Contributor

    Reported in #19530.

  22. UnrealKaraulov commented on Feb 11, 2025

    @UnrealKaraulov

    Same issue

    Image

    how to fix it?

  23. songshinyoung commented on Mar 20, 2025

    @songshinyoung

    I am using Windows 10.
    The language is set to Korean.
    When my file is of the "Ansi" type, there is an issue where Korean comments break due to the same problem.
    I confirmed that after changing the problematic file to the UTF-8 type, the Korean comments no longer break.
    I recommend a tool or method to change file encoding to UTF-8.
    However, support is needed to ensure that characters do not break, regardless of the type of file.

  24. vico93 commented on Sep 25, 2025

    @vico93

    Is still an issue for me - i sometimes do things in PAWN for Open.MP (a spiritual sucessor of SA:MP) that requires the source files to be encoded as Windows-1252 (ANSI). Diffs of those files always show the accents with the "?" character.

    Image
  25. added theissue type on Mar 9, 2026
  26. wezzzyrek1 commented on May 21, 2026

    @wezzzyrek1

    Same here. If file is encoded using ANSI charset then all breaks

    Image

    In this case the file is encoded using 949 Korean. Changing gile encoding to UTF8 is not a solution in many cases, as we use 949 on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpitchpriority-3

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions