Author Topic: Standardizing treating Resource Scripts (.rc) as text files in GitHub  (Read 4427 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Git treats Microsoft specific Resource Scripts (.rc) files as binary and not text files even though they are text files.

I am planning on standard adding a .gitattributes file to our Git projects that contain resources that includes the following line:

Code: [Select]
*.rc diff

This will allow seeing the number of lines changed when committing from my local machine as opposed to just saying binary (-). Tested and works with TortoiseGit. Unfortunately, GitHub still seems to flag it as binary. Not sure how to prevent that yet.

You can see GitHub flagging as binary here: https://github.com/Brett208/OP2MissionYukonTrail/commit/1cf44dabfdb43e013b47e536876a2940d84a525f

-Brett

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
« Reply #1 on: February 19, 2019, 02:26:32 AM »
Ahh yes, I've noticed some of those binary markers. Resource files are encoded as UTF-16, which Git treats as binary. I've heard SVN also treated such files as binary in the past, though I don't know if that's still true.

Some related links:
Visual Studio support request to support UTF8 (Closed as won't fix, though with some partial workarounds in the comments)
Resource Compiler #pragma code_page directive
StackOverflow topic about using UTF-8 encoding

It seems you can use UTF-8 encoding, with a special directive, but you won't be able to edit the file from Visual Studio without it messing things up when it saves changes.

Most of those comments are 4+ years old, though I somehow suspect nothing has changed since then.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
« Reply #2 on: February 19, 2019, 07:27:50 PM »
Makes me grumpy to see that both Visual Studio doesn't feel it is worth their time to support UTF8 encoding in resources files and Git doesn't want to support UTF-16 at all. Both seem like reasonable requests to me?

I didn't hear anyone object to adding the .gitattributes file, so I'll plan on that in Outpost Universe Repos that contain Microsoft specific .rc files.

-Brett

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
« Reply #3 on: February 20, 2019, 12:34:51 PM »
Agreed. The lack of support on both ends is a little annoying.

I looked a little more into this. It seems on the Git side, the lack of support is more specifically with the diff tool used by Git. That diff tool is configurable. You can use an alternate diff tool that is UTF-16 aware. That would seem to be more of a local solution though, not something that is stored in the repository and used by other people. As such, I don't see that being used up on GitHub.

I suppose that at least explains the solution you found of setting "diff" for the file. That seems to match all the other partial solutions that I saw online.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
« Reply #4 on: February 20, 2019, 02:53:06 PM »
Git probably will never support it because Torvalds is an ass like that.

Microsoft ... well, what can I say? You'd think they'd do the UTF-8 thing, should be simple enough, no? It's not like they have the entire resources of their entire development team or anything. :/