desktop: non-UTF8 characters are not rendered correctly in Changes and History diff

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: https://github.com/vczh-libraries/GacUI/commit/92945be6a7fe72c037409cb60372e8ca5be3975f , 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.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 7
  • Comments: 29 (15 by maintainers)

Most upvoted comments

I have the same issue in the Changes tab when working with ANSI (Windows 1252) encoded text files. Special ANSI characters render as “?” blocks.

add ability in the desktop gui to play with the .gitconfig and .gitignore these backend files almost no one knows how to use do to no good documentation and it not being in the desktop gui. the ignore kind of is. I literally look it up on google and it tells you to use a linux command which doesn’t exist on windows and then it doesn’t work for .gitignore nor do I know how to use it

@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.

https://github.com/desktop/desktop/blob/c464fff0c4b7d679960ff2e3ddac0bdda2cc1348/app/src/lib/git/diff.ts#L358-L361