Outpost Universe Forums

Projects & Development => Projects => Topic started by: Vagabond on February 16, 2019, 09:48:15 PM

Title: Standardizing treating Resource Scripts (.rc) as text files in GitHub
Post by: Vagabond on February 16, 2019, 09:48:15 PM
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
Title: Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
Post by: Hooman 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 (https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/3082310-support-rc-files-in-utf8-encoding) (Closed as won't fix, though with some partial workarounds in the comments)
Resource Compiler #pragma code_page directive (https://docs.microsoft.com/en-us/windows/desktop/menurc/pragma-directives)
StackOverflow topic about using UTF-8 encoding (https://stackoverflow.com/questions/15244065/error-rc2135-in-c-project-due-to-utf-8-encoding-of-rc-file)

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.
Title: Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
Post by: Vagabond 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
Title: Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
Post by: Hooman 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.
Title: Re: Standardizing treating Resource Scripts (.rc) as text files in GitHub
Post by: leeor_net 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. :/