Is there any way to make git gui
display and show diffs for UTF16 files somehow?
I found some information, but this is mostly referring to the command l
I ran into a similar issue.
I would like to improved on the accepted answer, since it has a small flaw. The problem I ran into was that if the file did not exist, I received this error:
conversion to cannot unsupported
I changed the commands so that a file is not required. It uses only stdin/stdout. This fixed the issue. My .git/config file now looks like this:
[filter "mixedtext"]
clean = "GITTMP=$(mktemp);TYPE=$( tee $GITTMP|file -b --mime-encoding - ); cat $GITTMP | iconv -sc -f $TYPE -t utf-8; rm -f $GITTMP"
smudge = "GITTMP=$(mktemp);TYPE=$( tee $GITTMP|file -b --mime-encoding - ); cat $GITTMP | iconv -sc -f utf-8 -t $TYPE; rm -f $GITTMP"
required = true
To create the entries in your .git/config file use these commands:
git config --replace-all filter.mixedtext.clean 'GITTMP=$(mktemp);TYPE=$( tee $GITTMP|file -b --mime-encoding - ); cat $GITTMP | iconv -sc -f $TYPE -t utf-8; rm -f $GITTMP'
git config --replace-all filter.mixedtext.smudge 'GITTMP=$(mktemp);TYPE=$( tee $GITTMP|file -b --mime-encoding - ); cat $GITTMP | iconv -sc -f utf-8 -t $TYPE; rm -f $GITTMP'
git config --replace-all filter.mixedtext.required true
My .gitattributes file looks like this:
*.txt filter=mixedtext
*.ps1 filter=mixedtext
*.sql filter=mixedtext
Specify only the files that might be an issue otherwise the clean/smudge has to do more work (temp files).
We also bulk converted the UTF-16le files in git to UTF-8 since this is the most compact and portable encoding for UTF. The same iconv command used in clean and smudge was perfect for permanently converting the files.
The nice thing about the clean/smudge commands is that even if a file is checked in with, say, UTF-16le, the diff will still work.